I created a UserControl
which contains Text Property
.
Text Property
:
private string _Text;
public string Text
{
set
{
_Text= value;
}
get
{
return _Text;
}
}
Now, I want to get TextValueChanged
event of Text Property
when I type into Text Property
. What should I do? Thanks in advance.
In Wpf, first create a different class and create a for Notify property changed viewmodelbase class:
public abstract class ViewModelBase : INotifyPropertyChanged, IMVVMDockingProperties
{
protected void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
then where you are implementing this property just add one more line of code:
private string _Text;
public string Text
{
set
{
_Text= value;
}
get
{
return _Text;
**OnPropertyChanged("Text");**
}
}
also if you want to get notified on every character entered event add this to your binding:
Binding="{Binding Path=Text, **UpdateSourceTrigger=PropertyChanged**, Mode=TwoWay}"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments