DataStateBehavior (Blend SDK for WPF)

You can use the DataStateBehavior behavior to switch between two visual states based on whether a conditional property binding evaluates to True or to False.

With the DataStateBehavior behavior, you can compare two values. One value comes from a binding. You can declare the other value explicitly. If the two values are equal, the visual state specified for True is activated. If the two values are not equal, the visual state specified for False is activated.

To add a DataStateBehavior

  1. In the Assets panel, click Behaviors, and then drag DataStateBehavior onto the object that you want to apply the behavior to. The Common Properties category appears in the Properties panel.

    Note

    The object to which the behavior is attached provides the context for the behavior.

  2. In the Common Properties category, in the Binding box, specify the binding that you want. You can use the Artboard element picker Artboard Element Picker (data-bound) to select the binding.

    DataStateBehavior

  3. In the Value box, specify the value that you want to compare. Type a value into the Value box, or click Advanced options 12e06962-5d8a-480d-a837-e06b84c545bb to bind the data.

  4. In the TrueState and FalseState drop-down lists, pick the visual state that you want to be triggered depending on whether the values from the Binding and Value properties are equal.

    If the two values are equal, the visual state specified for True is activated. If the two values are not equal, the visual state specified for False is activated.