How can I Have a WPF EventTrigger on a View trigger when the underlying Viewmodel dictates it should?

后端 未结 4 1709
小蘑菇
小蘑菇 2020-11-29 04:37

Here\'s the scenario:

I have the following user control, the idea is that it\'s view model should be able to signal to the view that it needs to \"Activate the Glow\

4条回答
  •  遥遥无期
    2020-11-29 05:06

    I believe you would have to bind to a RoutedEvent instance, not a CLR event.

    I haven't tried it, but something like this should work:

    public class UnitView
    {
        public static readonly RoutedEvent ActivateGlowEvent
            = EventManager.RegisterRoutedEvent(
                  "ActivateGlow", RoutingStrategy.Bubble,
                  typeof(RoutedEventHandler), typeof(UnitView)
              );
    
        public void RaiseActivateGlowEvent()
        {
            RaiseEvent(new RoutedEventArgs(ActivateGlowEvent));
        }
    }
    

提交回复
热议问题