Begin animation when ContentControl.Content is changed

后端 未结 2 1199
暗喜
暗喜 2021-01-06 08:02

I\'m trying to fire an animation when a content control such as Button or ContentControl changes its content. My initial thoughts were to do this:

        &l         


        
2条回答
  •  感动是毒
    2021-01-06 08:40

    There is no CLR-event for ContentChanged (much less a RoutedEvent required for EventTriggers) unfortunately. However, given that you're dealing with a custom control, you can override the metadata for the Content property and provide your own callback within the control.

    This may be about what you're looking for here

    Obviously he's created a CLR-event to propagate content changes externally; you could also do the same just using a RoutedEvent instead.

    Additional reading on OverrideMetadata here

提交回复
热议问题