First, I want to say that the example below is simplification. Suppose you have linked a WPF control.
<Window Title="Window1" Height="300" Width="300"> <Grid> <StackPanel> <TextBox Text="{Binding Name}" Margin="10"/> <Button HorizontalAlignment="Center" Content="Click Me" Margin="5" Padding="2" Click="OnButtonClick" /> </StackPanel> </Grid> </Window>
The window is bound to the Person class, which implements INotifyPropertyChanged and has a name installer in the form
public string Name { get { return _name; } set { _name = "Some Name"; OnPropertyChanged("Name"); } }
those. _name is assigned to "Some Name" whenever a user tries to change it from the user interface. But this sample does not work. I changed the name in the TextBox to some value by clicking on the tab, forcing the focus to move to the Button, and the value in the TextBox remains unchanged, although the PropertyChanged event was raised.
Could you explain to me why this is happening? Since I understand that the PropertyChanged event forces the UI to re-read the values ββfrom the properties and display them, but in my example, the value in the text field with the database binding is not updated.
Yet again. I understand that this is a poor implementation of the property, but I want to repeat that this is a simplification. This is just a sample. But in any case, PropertyChanged signals that the property has been changed and needs to be updated, but this is not so.
data-binding wpf inotifypropertychanged
Oleg
source share