I add code in .cs
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); }
}
in xaml
<TextBlock Text="{Binding lbStatus}" Style="{StaticResource PhoneTextNormalStyle}" Height="24"/>
And then add a global value
private string a = "Test";
and in init function
this.lbStatus = a;
Finally I add a button and change a’s value,the TextBlock doesn’t change!why?
Thx~~~~
String, in .NET, is an immutable type. When you type:
You set lbStatus to a reference to the string currently pointed to by the
avariable. Later, when you change a:You’re not going to change
this.lbStatus, since you’re assigning theavariable to a completely new string instance.