Possible Duplicate:
Why does the binding update without implementing INotifyPropertyChanged?
I have WPF:
<TextBlock Grid.Row="0" Text="{Binding SomeProperty}" />
<TextBox Grid.Row="1" Text="{Binding SomeProperty, UpdateSourceTrigger=PropertyChanged}" />
Bound to
class MyModel1
{
string _someProperty = string.Empty;
public string SomeProperty
{
get { return _someProperty; }
set { _someProperty = value; }
}
}
It allso works with:
class MyModel
{
public string SomeProperty { get; set; }
}
As You see there is no Property Change notifications, but TextBlock is updated while i am typing to TextBox.
I am using Visual C# express 2010, standard WPF app project template, standard contols, no snippets, nothing additional, with .NET 4 client profile.
- Question 1: Why it works?
- Question 2: Is that new feature of .NET 4?
- Question 3: How I could get notifications about property changes from
my code without implementing any events in my model?
Thank You
1 if that’s work, WPF’s data binding engine will data bind to
PropertyDescriptorinstance which wraps the source property if the source object is a plain CLR object and doesn’t implement INotifyPropertyChanged interface.PropertyDescriptor.AddValueChanged()method permit to subscribe to notification.The change is not synchronized as desired, we use
INotifyPropertyChangedin order to customize this aspect.2 You can read this article it’s interessant
Link : http://msdn.microsoft.com/en-us/library/bb613588.aspx