Do Triggers/DataTrigger return to previous state if it is no longer true in WPF?

后端 未结 1 1784
北荒
北荒 2021-01-18 13:03

While reading about DataTrigger on MSDN, it says

Represents a trigger that applies property values or performs actions when the bound data meets a spe

相关标签:
1条回答
  • 2021-01-18 13:29

    What you are telling, is correct.

    As for actual doc to prove this, search from here:

    http://msdn.microsoft.com/en-us/library/ms745683.aspx

    http://msdn.microsoft.com/en-us/library/system.windows.trigger.aspx

    "Remarks section"

    WPF defines properties that correspond to end-user actions, such as the IsMouseOver property that is set to true when the user hovers the cursor over a UIElement or the corresponding IsMouseOver property of a ContentElement. Representing end-user actions in property values, along with the Trigger element, allows WPF styles to change property values based on those end-user actions, all from within markup.

    The properties changed by triggers are automatically reset to their previous value when the triggered condition is no longer satisfied. Triggers are optimized for transient states which are expected to change and return to original state, such as IsPressed on Button and IsSelected on ListBoxItem. The Property of interest must be a dependency property.

    Note that you must specify both the Property and Value properties on a Trigger for the trigger to be meaningful. If one or both of the properties are not set, an exception is thrown.

    good luck :)

    0 讨论(0)
提交回复
热议问题