Timmy Kokke - Behaviors SDK
When the release candidate of Visual Studio 2013 came available, so did the Behaviors SDK. The Behaviors SDK is somewhat similar to the Expression Blend SDK you might have used before when using Behaviors and Actions. Along with the SDK come a couple of actions and behaviors you can use in your Windows Store applications right away.
What are they?
Both behaviors and actions are small pieces of code that can be reused throughout your projects. In the case of the new Behaviors SDK the only thing you need to do is implement an interface. A behavior adds some behavior to an element in your application. A behavior has a method that is invoked when the behavior is attached to a Dependency Object. It also has a method that is invoked when it is detached. An action contains only one method that is invoked when a certain condition is met. This condition can be a event that is raised, or a state of data or well pretty much everything.
Those of you who are used to working with behaviors and actions on other platforms might miss the triggers. Triggers where used to work together with actions, and presented the reason for an action to be executed. In the new Behaviors SDK triggers are no longer there. They are replaced by behaviors.
What’s in the SDK?
The Behaviors SDK consists of two parts. One (Microsoft.Xaml.Interactivity) contains the tools you need to create your own behaviors and actions(more about this is a sec). The other (Microsoft.Xaml.Interactions) contains a few of the most commonly used behaviors and actions(which are build with the interfaces from the first part b.t.w.). Not everything you might be used to working with from other platforms is included in de SDK, but I’m pretty sure these will be available through open source channels.
Let’s just go over the actions and behaviors included in de SDK.
Actions:
- CallMethodAction : An action that calls a method on a specified object when invoked.
- ChangePropertyAction : An action that will change a specified property to a specified value when invoked.
- GoToStateAction : An action that will transition a FrameworkElement to a specified VisualState when executed.
- InvokeCommandAction : Executes a specified ICommand when invoked.
- NavigateToPageAction : An action that switches the current visual to the specified Page.
- ControlStoryboardAction : An action that will change the state of the specified Storyboard when executed.
- PlaySoundAction : An action that will play a sound to completion.
Behaviors:
- DataTriggerBehavior : A behavior that performs actions when the bound data meets a specified condition.
- EventTriggerBehavior : A behavior that listens for a specified event on its source and executes its actions when that event is fired.
- IncrementalUpdateBehavior : A behavior that allows incremental updating of ListView and GridView contents to support faster updating. By attaching this behavior to elements in the ItemTemplate used by these views, some of the updates can be deferred until there is render time available, resulting in a smoother experience.
The other part contains two interfaces you need when building your own: IAction and IBehavior. There are some attributes and helper classes you can use too.
...
BlendBehaviors.NET
Welcome to BlendBehaviors.NET. As a XAML developer I use behaviors a lot. Like most developers, I don't like writing the same code over and over. Let us all share our behaviors and actions so we have to write even less.
Something I need to look more into, especially in my WPF world...
No comments:
Post a Comment
NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...
ALL comments are moderated. I will review every comment before it will appear on the blog.
Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...
I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...
Please see my comment policy for more information if you are interested.
Thanks,
Greg
PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...