wpf - DataStateBehavior for Enum instead of bool? String? -
Is there an easy way to force VisualStates of enum values in WPF? Kinda is like DataStateBehavior, but for an Enum?
The best way is to just move forward and apply a behavior that does the same -
Public class EnumStateBehavior: Behavior & lt; Framework Element & gt; {PUBLIC INFORMATION PROPERTY {Received {Return (Object) Gateville (Anemproperty Property); } Set {Set Value (EnumPropertyProperty, Value); }} // EnumProperty uses dependency properties in the form of a backing store, this animation, style, binding, etc. ... public static Read Only DependencyProperty EnumPropertyProperty = DependencyProperty.Register ("EnumProperty", typeof ( Object), typeof (EnumStateBehavior), new UIPropertyMetadata (zero, EnumPropertyChanged)); Static void EnumPropertyChanged (Object Sender, DependencyPropertyChangedEventArgs e) {if (e.NewValue == Faucet) Return; EnumStateBehavior eb = EnumStateBehavior as the sender; VisualStateManager.GoToElementState (eb.AssociatedObject, e.NewValue.ToString (), true); }}
The usage is very simple - use this type as:
& lt; I: Interaction.Behaviors & gt; & Lt; Local: EnumStateBehavior EnumProperty = "{Binding MyEnumProperty}" /> & Lt; / I: Interaction.Behaviors & gt;
Comments
Post a Comment