IdentityMine

| Tags: WPF

originally posted by Karim Hernandez: (link) - please comment at original post

I finally had a chance to explore Expression Blend’s Interactivity SDK a bit and put together a simple HelloWorld app using it with Blend 3.

sshot

At the center is a rough custom Behavior that is able to share the visual state of controls that are bound to the same data object. Once the behavior was functional, I simply needed to add the behavior to two Buttons, bind the buttons to the same data, and wire an event to trigger the state change.

<Button MouseEnter="enterHandler" MouseLeave="leaveHandler">
  <i:Interaction.Behaviors>
    <local:SharedVisualStateBehavior Source="{Binding}" />
  </i:Interaction.Behaviors>
</Button>

private void enterHandler(object sender, MouseEventArgs e)
{
  SharedVisualStateBehavior.GoToSharedState(
    (Control)sender, "MouseOver");
}
private void leaveHandler(object sender, MouseEventArgs e)
{
  SharedVisualStateBehavior.GoToSharedState(
    (Control)sender, "Normal");
}

Because of the need to call a static method to actually make use of it, meaning it’s not selfcotnained, it doesn’t really qualify as a Behavior.  The ideal SharedVSM would be able to take input in the form of VisualState parameters and possibly a trigger, in order to notify the shared controls of state changes.  It’s a work in progress.

Thanks to Kuler for the theme, Josh Smith for ObserveableObject from MVVM Foundation, and Pete Blois for BindingListener from Expression Samples.

Remember to please comment at original post: (link)

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInPin on PinterestShare on RedditShare on TumblrEmail this to someoneDigg thisFlattr the authorShare on StumbleUpon

Comments are closed.