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