Saturday, February 04, 2012
Blog
Oct 6

Written by: New Age Solution
10/6/2009 2:02 PM  RssIcon

DataStateSwitchBehavior is very useful when implementing any kind of MVVM. Thing of DataSwitchBehavior as switch statement of states. Based on bound data appropriate state will be selected.

"DataStateSwitchBehavior" extremely useful and a must in order to succesfully implement MVVM in Silverlight. Imagine having a control with lights red, yellow and green. And based on bound data control is responsible for lighting up the proper light. This also allows seperation of work between graphic designer and developer in that designer will create multiple states for highlighting the lights (on and off) and developer hooking up those states to the view model controller.

- Go to http://expressionblend.codeplex.com/ and download binaries

- Add reference to Expression.Samples.Interactivity.dll and Microsoft SDKs\Expression\Blend 3\Interactivity\Libraries\Silverlight\System.Windows.Interactivity.dll

- Add namespace to user control as seen highlighted bold

<UserControl

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

    xmlns:si="clr-namespace:Expression.Samples.Interactivity;assembly=Expression.Samples.Interactivity"

 

OR

 

- From Blend Under Assets drag and drop DataSwitchBehavior to the control that requires state to be selected from multiple states based on binding data.
 

 

- Bind the data

 

 

<i:Interaction.Behaviors>

    <si:DataStateSwitchBehavior Binding="{Binding CanLightRed, Mode=OneWay}">

        <si:DataStateSwitchCase State="RedLayerOff" Value="false"/>

        <si:DataStateSwitchCase State="RedLayerOn" Value="true"/>

    si:DataStateSwitchBehavior>

i:Interaction.Behaviors>

 

That is all to use it.

 

Download the code sample with DataBehavior and basic MVVM implementation

 

 

 


Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 


Tags


Blog Archive


Blog List


Search Blog


Google Reader


Blog Comments
re:
I’m impressed. Very informative and trustworthy blog does exactly what it sets out to do. I’ll bookmark your weblog for future use.

Joseph
www.joeydavila.com
Your online Library
Re: Silverlight 4 PathListBox
Nope you dont need blend.
Re: Silverlight 4 PathListBox
I have visual studio 2010, do you have to have expression blend to execute the above code? Thanks.
re:
I’m impressed. Very informative and trustworthy blog does exactly what it sets out to do. I’ll bookmark your weblog for future use.

Joseph
www.joeydavila.com
Your online Library
re:
I’m impressed. Very informative and trustworthy blog does exactly what it sets out to do. I’ll bookmark your weblog for future use.

Joseph
www.joeydavila.com
Your online Library
Re: How to fix TF215032 when trying to delete Build Definition from TFS?
Thanks you very much.
Re: DotNetNuke PermanentRedirect Error
Thanks so much for posting this! It fixed my issue.
Re: Why we are using our own custom blog using DotNetNuke?
Word Press is good too. see Blog.ToeTapz.com. Depends on what you need. I use DNN blog because it gives me ultimate control on what I want and what I need. Also I need to be able to upload Silverlight demo so I use DNN. BlogToeTapz.com I recently got is using word press and I been happy with it so far.
I am testing DNN blogs and they are not as good as blogger.com
Are there any other DNN blogs we can use for this?

http://newmediaworlds.blogspot.com/





Re: How to add Google Email, Calendar, and contacts to Blackberry and iPhone?
Great and detail instructions. I got just got my Blackberry 8350 and it's a very useful information for me as a newbie.


Syndicate  

Privacy Statement  |  Terms Of Use
Copyright 2010 New Age Solution