<?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; IdentityMine</title>
	<atom:link href="http://www.dragonshed.org/blog/tag/identitymine/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>Thu, 12 Jan 2012 00:04:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<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>
		<item>
		<title>radiobuttons in a datatemplate in silverlight</title>
		<link>http://www.dragonshed.org/blog/2009/03/08/radiobuttons-in-a-datatemplate-in-silverlight/</link>
		<comments>http://www.dragonshed.org/blog/2009/03/08/radiobuttons-in-a-datatemplate-in-silverlight/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 09:33:37 +0000</pubDate>
		<dc:creator>Karim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[attached behavior]]></category>
		<category><![CDATA[IdentityMine]]></category>
		<category><![CDATA[Samples]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.dragonshed.org/blog/?p=211</guid>
		<description><![CDATA[I was recently asked by a customer, “Why doesn’t RadioButton.GroupName work when a single RadioButton is put in a DataTemplate within an ItemsControl?” I had no answer. When I tried it out myself, lo and behold, two checked RadioButtons were staring back at me. A quick search told me that others have encountered this issue, [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently asked by a customer, “Why doesn’t RadioButton.GroupName work when a single RadioButton is put in a DataTemplate within an ItemsControl?”  I had no answer.  When I tried it out myself, lo and behold, two checked RadioButtons were staring back at me.  A quick search told me that others have encountered this issue, and none had found a solution based in markup.</p>
<p>To illustrate the mechanics of Attached Behaviors, a topic that I had been reviewing with my customer, I decided to implement a working RadioButtonGroup as one.  Simply use the attached property in place of RadioButton.GroupName, and the behavior takes care of the rest.</p>
<pre style="font-size:1em;line-height:1.2em;"><span style="color:#0000ff;">&lt;</span><span style="color:#a31515;">ItemsControl </span><span style="color:#ff0000;">ItemsSource</span><span style="color:#0000ff;">="{</span><span style="color:#a31515;">Binding </span><span style="color:#ff0000;">DataCollection</span><span style="color:#0000ff;">}"&gt;
</span>  <span style="color:#0000ff;">&lt;</span><span style="color:#a31515;">ItemsControl.ItemsPanel</span><span style="color:#0000ff;">&gt;
</span><span style="color:#0000ff;">    </span><span style="color:#0000ff;"><span style="color:#0000ff;">&lt;</span><span style="color:#a31515;">ItemsPanelTemplate</span><span style="color:#0000ff;">&gt;
    </span></span><span style="color:#0000ff;">  &lt;</span><span style="color:#a31515;">StackPanel </span><span style="color:#ff0000;">Orientation</span>=<span style="color:#0000ff;">"Horizontal"</span><span style="color:#a31515;"> </span><span style="color:#0000ff;">/&gt;
</span><span style="color:#0000ff;"><span style="color:#0000ff;">    </span></span><span style="color:#0000ff;">&lt;/</span><span style="color:#a31515;">ItemsPanelTemplate</span><span style="color:#0000ff;">&gt;
</span><span style="color:#0000ff;">  &lt;/</span><span style="color:#a31515;">ItemsControl.ItemsPanel</span><span style="color:#0000ff;">&gt;
  &lt;</span><span style="color:#a31515;">ItemsControl</span><span style="color:#a31515;">.</span><span style="color:#a31515;">ItemTemplate</span><span style="color:#0000ff;">&gt;
    &lt;</span><span style="color:#a31515;">DataTemplate</span><span style="color:#0000ff;">&gt;
      &lt;</span><span style="color:#a31515;">RadioButton</span><span style="color:#0000ff;"> </span><span style="color:#ff0000;">Content</span><span style="color:#0000ff;">="{</span><span style="color:#a31515;">Binding</span><span style="color:#0000ff;"> </span><span style="color:#ff0000;">Name</span><span style="color:#0000ff;">}"
                   </span><span style="color:#ff0000;">b</span><span style="color:#0000ff;">:</span><span style="color:#ff0000;">RadioButtonGroup.Name</span><span style="color:#0000ff;">="1"/&gt;
    &lt;/</span><span style="color:#a31515;">DataTemplate</span><span style="color:#0000ff;">&gt;
  &lt;/</span><span style="color:#a31515;">ItemsControl</span><span style="color:#a31515;">.</span><span style="color:#a31515;">ItemTemplate</span><span style="color:#0000ff;">&gt;
</span><span style="color:#0000ff;">&lt;/</span><span style="color:#a31515;">ItemsControl</span><span style="color:#0000ff;">&gt;</span></pre>
<p>One interesting detail about my implementation:  It can be used with ToggleButtons to achieve RadioButton-like behavior.</p>
<p><img class="aligncenter size-full wp-image-197" title="Screenshot" src="http://dragonshed.org/samples/radiobuttongroup/radiobuttons-attachedbehavior.png" alt="" width="298" height="64" /></p>
<p>The solution source is available <a href="http://dragonshed.org/samples/radiobuttongroup/RadioButtonGroup.zip">here</a>.  Feedback welcome.</p>
<p>Side note: Using reflector, I noticed that although RadioButton has all the necessary plumbing to group arbitrary radio buttons (and that code is remarkably similar to how a standard attachedbehavior is implemented), it relied on the &#8220;Logical Tree&#8221;, FrameworkElement.Parent, to scope group names to a common root node.  One side effect of using ItemsControl is that the ContentPresenters used to show an item&#8217;s DataTemplate are severed from their parents.  Parent is always null.  This attached behavior doesn’t use that, and in fact it does not scope the group Names at all, so be sure to choose unique names.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dragonshed.org/blog/2009/03/08/radiobuttons-in-a-datatemplate-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

