I have created this base class for INotifyPropertyChanged...
namespace BASECLASSES.HelperClasses
{
public class NotifyPropChangedBase : INotifyPropertyChanged
{
/// <summary>
/// The propertyChanged Event to raise to any UI object
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// The PropertyChanged Event to raise to any UI object
/// The event is only invoked if data binding is used
/// </summary>
/// <param name="propertyName"></param>
protected void RaisePropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
PropertyChangedEventArgs args = new PropertyChangedEventArgs(propertyName);
handler(this, args);
}
}
}
}
I have created a ViewModel which implements the base class here...
public class CheckoutVM : BASECLASSES.HelperClasses.NotifyPropChangedBase
{
private string fullName ;
public string FullName
{
get { return fullName; }
set
{
if (fullName != value)
{
fullName = value;
RaisePropertyChanged("FullName");
}
}
}
}
}
}
In XAML I have defined a namespace for the class...
xmlns:bcbcns="clr-Namespace:BASECLASSES.HelperClasses;assembly=BASECLASSES"
I have defined a window resource...
<Window.Resources>
<m:CheckoutVM x:Key="chkOutViewModel" />
</Window.Resources>
Set the DataContext to the main grid...
<Grid DataContext="{Binding Source={StaticResource chkOutViewModel}}">
Set the path for label content to...
<Label Name="txtContactCheckingOut" Content="{Binding Path=FullName}"/>
Next I set the label with this code...
List<GET_CONTACT_Result> contactResultList = modsqlContact.GET_CONTACT(contactID);
CheckoutVM checkOutContact = new CheckoutVM();
checkOutContact.FullName = contactResultList[0].cFULLNAME;
But the label is not set.
If I add a constructor to the ViewModel like this....
public CheckoutVM()
{
FullName = "XXXXXXXXXXXXXXXXX";
}
The label is set to XXXXXXXXXXXXXXXXX so the binding seems to be correct.
It is looking like the handler is always null. PLEASE HELP!!!! What am I doing wrong???