I found a notify property changed example for static properties in static class. but it doesn't update any changes in TextBlock. Here are the codes.
First binding is working with the "test" string in constructor but StaticPropertyChanged is always null.
public static class InteractionData
{
public static List<string> SelectedDirectories { get; set; }
private static string errorMessage { get; set; }
public static string ErrorMessgae
{
get { return errorMessage; }
set
{
errorMessage = value;
NotifyStaticPropertyChanged("errorMessage");
}
}
static InteractionData()
{
SelectedDirectories = new List<string>();
errorMessage = "test";
}
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
private static void NotifyStaticPropertyChanged(string propertyName)
{
if (StaticPropertyChanged != null)
StaticPropertyChanged(null, new PropertyChangedEventArgs(propertyName));
}
}
In View ...
xmlns:error ="clr-namespace:CopyBackup.Providers"
<TextBlock Text="{Binding Source={x:Static error:InteractionData.ErrorMessgae} ,Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
Wherever I change the property, TextBlock doesn't update.
Appreciate