首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

【WPF】 将类中的某个成员的其中一个属性作为绑定源,怎么写

2012-09-14 
【WPF】 将类中的某个成员的其中一个属性作为绑定源,如何写?public class D{//...public A a}public class

【WPF】 将类中的某个成员的其中一个属性作为绑定源,如何写?
public class D
{
 //...
  public A a;
}

public class A
{
 public string TextDemo{ get; set; }
}


主类中实例化:
public D d;

添加DataContext 
this.LayoutRoot.DataContext = d;


在XAML中添加TextBlock 并进行Text属性与d.a的TextDemo进行绑定,应该怎么写
<TextBlock Text="{Binding ...}" Background="LightBlue"/>

[解决办法]
多谢,接分了。

热点排行