public class ViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
private string _firstProperty;
public string FirstProperty
{
get{ return _firstProperty; }
set
{
if (_firstProperty == value)
return
else
_firstProperty = value;
OnPropertyChanged("FirstProperty");
//propertyName in parentheses must be the same as property name
}
}
}
XAML file
<TextBox Text="{Binding Path=FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
Brak komentarzy:
Prześlij komentarz