I have a class Manager on which I have implemented INotifyPropertyChanged. The class has a single nullable int property.
public class Manager : INotifyPropertyChanged
{
private int? managerid = 0;
public int? Managerid
{
get
{
return managerid;
}
set
{
managerid = value;
RaisePropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged([CallerMemberName]string prop = null)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(prop));
}
}
I have bind a single text box on my WinForm as:
Manager mgr = new Manager();
mgr.PropertyChanged += PropertyChanged_Mgr;
textbox.DataBindings.Add("Text", mgr, "Managerid");
Following is the hooked method:
static void PropertyChanged_Mgr(object sender, System.ComponentModel.PropertyChangedEventArgs e)
The problem is that that property change doesn't fire if the property is nullable. If I make the said property not nullable, it works fine. Any help will be highly appreciated