<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>design-time writer's block &#187; Behaviors</title>
	<atom:link href="http://www.dragonshed.org/blog/tag/behaviors/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dragonshed.org/blog</link>
	<description>deadly sharp lines, waves of sine, intersecting shapes with tweens and keysplines</description>
	<lastBuildDate>Wed, 10 Feb 2010 06:04:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>drafting behaviors</title>
		<link>http://www.dragonshed.org/blog/2009/07/27/drafting-behaviors/</link>
		<comments>http://www.dragonshed.org/blog/2009/07/27/drafting-behaviors/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 21:11:32 +0000</pubDate>
		<dc:creator>Karim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Behaviors]]></category>
		<category><![CDATA[Expression Blend]]></category>
		<category><![CDATA[IdentityMine]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.dragonshed.org/blog/?p=257</guid>
		<description><![CDATA[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.

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 [...]]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<p><a href="http://www.dragonshed.org/samples/sharedvisualstate/"><img title="Screenshot" src="http://www.dragonshed.org/samples/sharedvisualstate/sshot.png" alt="Screenshot" width="482" height="218" /></a></p>
<p>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.</p>
<pre style="font-size: 1em; line-height: 1.2em;"><span style="color: #a31515;"><span style="color: #3366ff;">&lt;</span>Button <span style="color: #ff0000;">MouseEnter</span><span style="color: #3366ff;">="enterHandler"</span> <span style="color: #ff0000;">MouseLeave</span><span style="color: #3366ff;">="leaveHandler"&gt;</span>
  <span style="color: #3366ff;">&lt;</span>i<span style="color: #3366ff;">:</span>Interaction.Behaviors<span style="color: #3366ff;">&gt;</span>
    <span style="color: #3366ff;">&lt;</span>local<span style="color: #3366ff;">:</span>SharedVisualStateBehavior <span style="color: #ff0000;">Source</span><span style="color: #3366ff;">="{</span>Binding<span style="color: #3366ff;">}" /&gt;</span>
  <span style="color: #3366ff;">&lt;</span><span style="color: #3366ff;">/</span>i<span style="color: #3366ff;">:</span>Interaction.Behaviors<span style="color: #3366ff;">&gt;</span>
<span style="color: #3366ff;">&lt;/</span>Button<span style="color: #3366ff;">&gt;

<span style="color: #000000;"><span style="color: #0000ff;">private void </span>enterHandler(<span style="color: #0000ff;">object </span>sender, <span style="color: #2b91af;">MouseEventArgs </span>e)
{
  <span style="color: #2b91af;">SharedVisualStateBehavior</span>.GoToSharedState(
</span></span></span><span style="color: #a31515;"><span style="color: #3366ff;"><span style="color: #000000;">  </span></span></span><span style="color: #a31515;"><span style="color: #3366ff;"><span style="color: #000000;">  </span></span></span><span style="color: #a31515;"></span><span style="color: #a31515;"><span style="color: #3366ff;"><span style="color: #000000;">(<span style="color: #2b91af;">Control</span>)sender, <span style="color: #993300;">"MouseOver"</span>);
}
<span style="color: #0000ff;">private </span><span style="color: #0000ff;">void </span>leaveHandler(<span style="color: #0000ff;">object </span>sender, <span style="color: #2b91af;">MouseEventArgs </span>e)
{
  <span style="color: #2b91af;">SharedVisualStateBehavior</span>.GoToSharedState(
</span></span></span><span style="color: #a31515;"><span style="color: #3366ff;"><span style="color: #000000;">  </span></span></span><span style="color: #a31515;"><span style="color: #3366ff;"><span style="color: #000000;">  </span></span></span><span style="color: #a31515;"><span style="color: #3366ff;"><span style="color: #000000;">(<span style="color: #2b91af;">Control</span>)sender, <span style="color: #993300;">"Normal"</span>);
}</span></span></span></pre>
<p>Because of the need to call a static method to actually make use of it, meaning it&#8217;s not selfcontained, it doesn&#8217;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&#8217;s a work in progress.</p>
<p><em>Thanks to Kuler for the <a href="http://kuler.adobe.com/#themeID/481195">theme</a>, Josh Smith for ObserveableObject from <a href="http://mvvmfoundation.codeplex.com/">MVVM Foundation</a>, and Pete Blois for BindingListener from <a href="http://expressionblend.codeplex.com/">Expression Samples</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dragonshed.org/blog/2009/07/27/drafting-behaviors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
