I have searched for hours and still do not know why when changes are made to my database why it is not reflecting immediately on the TextBlock item in my ListBox.
Here is my class:
class Event : INotifyPropertyChanged
{
public string Name { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public string CustomerName
{
get
{
return this.Name;
}
set
{
if (value != this.Name)
{
this.Name = value;
NotifyPropertyChanged("CustomerName");
}
}
}
private void NotifyPropertyChanged(String propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Here is my xaml
<ListBox x:Name="lb_events" ItemTemplate="{DynamicResource EventsTemplate}"...
<DataTemplate x:Key="EventsTemplate"...<StackPanel><TextBlock Text="{Binding CustomerName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
The TextBlock displays the Event.Name assigned, but when I change the data in the database, changes are not made until I reinitialize the binding.