I have a button whose content is binded with ViewModel’s property called Test.
<Button Content="{Binding Test, Mode=TwoWay}"
Name="button1"Click="button1_Click" />
On click of the button I am changing its content
private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
{
button1.Content = "Yellow";
}
But in the property setter I would like to override the content being set and set my own content.
Following is the code for same:
string _test;
public string Test
{
get
{
return _test;
}
set
{
_test = "Something" + System.DateTime.Now.ToString();
RaisePropertyChanged(() => Test);
}
}
Now the problem is button’s content is getting set as “Yellow” instead of that it should be something like “Something…”
If I bind this property with textbox at the same time, there the value is being displayed in the correct manner.
Note: this is just an example and focus of my question is raisepropertychanged.
Please help.
Thanks everyone for your answers. I have figured out that it worked when you run it in the Non-debug mode. But in case of Call Back it will not work even in non-debug mode.
I have finally got the solution which mentioned in the article http://info.titodotnet.com/2011/08/silverlight-dependency-property-clr.html
Cheers!