1
我加入的.csTextBlock绑定?
public static readonly DependencyProperty lbStatusProperty =
DependencyProperty.Register("lbStatus", typeof(string), typeof(SingleTalkView),
new PropertyMetadata(""));
public string lbStatus
{
get { return (string)GetValue(lbStatusProperty); }
set { SetValue(lbStatusProperty, value); }
}
在XAML
<TextBlock Text="{Binding lbStatus}" Style="{StaticResource PhoneTextNormalStyle}" Height="24"/>
然后代码添加一个全局值
private string a = "Test";
和初始化函数
this.lbStatus = a;
决赛我添加一个按钮并更改a值,TextBlock不会改变!为什么? Thx ~~~~
哦......我如何结合TextBlock的? – Yagami 2012-03-29 05:38:44
@Yagami通常,你会绑定到实现INotifyPropertyChanged的类的Property。你可以参考我关于WPF数据绑定的文章,这与Windows Phone中的绑定非常相似:http://reedcopsey.com/2009/11/25/better-user-and-developer-experiences-from-windows-形式对WPF与 - MVVM部分-4-数据绑定/ – 2012-03-29 05:42:01