<?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>Silverlight &#124; WPF &#124; Microsoft.Net &#187; x:Name</title>
	<atom:link href="http://joel.neubeck.net/tag/xname/feed/" rel="self" type="application/rss+xml" />
	<link>http://joel.neubeck.net</link>
	<description>Simplifing structure without changing results</description>
	<lastBuildDate>Fri, 01 Apr 2011 21:34:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Tip: Don&#8217;t be scared to use x:Name in XAML</title>
		<link>http://joel.neubeck.net/2009/02/tip-dont-be-scared-to-use-xname-in-xaml/</link>
		<comments>http://joel.neubeck.net/2009/02/tip-dont-be-scared-to-use-xname-in-xaml/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 20:30:49 +0000</pubDate>
		<dc:creator>joel</dc:creator>
				<category><![CDATA[Industry]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tip]]></category>
		<category><![CDATA[x:Name]]></category>
		<category><![CDATA[Xaml]]></category>

		<guid isPermaLink="false">http://joel.neubeck.net/?p=336</guid>
		<description><![CDATA[Yesterday I was working on some Silverlight production and needed to create a custom UserControl that had some text. The trick was that I wanted the user placing the control to choose which color the text would be, inturn effecting the second key frame on a simple ColorAnimationUsingKeyFrames My animation was really simple, I wanted [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I was working on some Silverlight production and needed to create a custom UserControl that had some text.  The trick was that I wanted the user placing the control to choose which color the text would be, inturn effecting the second key frame on a simple ColorAnimationUsingKeyFrames</p>
<p>My animation was really simple, I wanted the text to start out as white old for a few milliseconds then fade into my dynamic color.  My first tendency was to just create the Storyboard procedurally, but did not want to lose the &#8220;blendability&#8221; of my control.   Then it dawned on me how simple the solution was.  Just name the second KeyFrame.</p>
<p>All to often we forget that we can give virtually any XAML node an x:Name and the framework will create a private reference to the element.</p>

<div class="wp_syntax"><div class="code"><pre class="c-sharp" style="font-family:monospace;">&lt;SplineColorKeyFrame x:Name=&quot;destColor&quot; KeyTime=&quot;00:00:00.3000000&quot; 
      Value=&quot;{StaticResource GemColor}&quot;/&gt;</pre></div></div>

<p><a href="http://joel.neubeck.net/wp-content/uploads/2009/02/tip1.png"><img class="alignleft size-full wp-image-337" title="tip1" src="http://joel.neubeck.net/wp-content/uploads/2009/02/tip1.png" alt="tip1" width="450" height="198" /></a><br style="clear:both"/><br />
Once we have named our node, in the corresponding code behind we can simply reference any property from that element.</p>

<div class="wp_syntax"><div class="code"><pre class="c-sharp" style="font-family:monospace;">destColor.Value = Color.FromArgb(255, 10, 10, 10);</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://joel.neubeck.net/2009/02/tip-dont-be-scared-to-use-xname-in-xaml/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

