WPF weakly subscribe to the IsEnabledChanged event

276 views Asked by At

Is it possible to weakly subscribe to the UIElement.IsEnabledChanged event?

Neither the WeakEventManager<TEventSource, TEventArgs>

WeakEventManager<UIElement, DependencyPropertyChangedEventArgs>
          .AddHandler(uie, nameof(UIElement.IsEnabledChanged), Element_isEnabledChanged);

seems to work because DependencyPropertyChangedEventArgs do no extend TEventArgs.
Nor the PropertyChangedEventManager

PropertyChangedEventManager
                  .AddHandler(uie, Element_isEnabledChanged, nameof(UIElement.IsEnabled));

does work because UIElement does not implement INotifyPropertyChanged! How are people supposed to safely subscribe to that event?

0

There are 0 answers