I have created a dependency property on my WPF usercontrol which would be databound in my parent usercontrol. I have implemented the INotifyPropertyChanged
on my viewmodel to send notifications when the value changes.
User Control code:
public bool IsVisibile {
get { return (bool) GetValue(IsVisibileProperty); }
set { SetValue(IsVisibileProperty, value); }}
public static readonly DependencyProperty IsVisibileProperty =
DependencyProperty.Register("IsVisibile", typeof(bool), typeof(UserControl),
new PropertyMetadata(default(bool), VisiblePropertyChangedCallback));
private static void VisiblePropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
if (dependencyPropertyChangedEventArgs.NewValue != null)
{
((UserControl) dependencyObject).IsVisibile = (bool) dependencyPropertyChangedEventArgs.NewValue;
}
}
Parent User Control usage:
<uc:UserControl IsVisible="{Binding IsViewModelVisible, UpdateSourceTrigger=PropertyChanged}"
If the "IsViewModelVisible" changes then the property changed event handler is not called and the property is not refreshed.
Any thoughts?