<?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; ImplicitStyleManager</title>
	<atom:link href="http://joel.neubeck.net/tag/implicitstylemanager/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>RatingControl with Theme support</title>
		<link>http://joel.neubeck.net/2008/11/ratingcontrol-theme/</link>
		<comments>http://joel.neubeck.net/2008/11/ratingcontrol-theme/#comments</comments>
		<pubDate>Sun, 09 Nov 2008 06:37:18 +0000</pubDate>
		<dc:creator>joel</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[ControlTemplate]]></category>
		<category><![CDATA[ImplicitStyleManager]]></category>
		<category><![CDATA[Rating Control]]></category>
		<category><![CDATA[Theming]]></category>

		<guid isPermaLink="false">http://joel.neubeck.net/?p=302</guid>
		<description><![CDATA[This past Wednesday I was asked to present at the Phoenix Silverlight users group on the topic of writing custom controls. Back a few months ago I created a very simple version of a Silverlight Rating control and thought it would be a great example to demonstrate how to leverage Control Templates, Visual State manager [...]]]></description>
			<content:encoded><![CDATA[<p>This past Wednesday I was asked to present at the Phoenix Silverlight users group on the topic of writing custom controls.  Back a few months ago I created a very simple version of a Silverlight Rating control and thought it would be a great example to demonstrate how to leverage Control Templates, Visual State manager and styling.  Back when I created the control I choose to use &#8220;/themes/generic.xaml&#8221; as a way to provide the default styling of my control.  This works great if a developer wants to tweek the layout of the control before using it in there project, but was never intended to skin the control at runtime.</p>
<p>A few weeks back around PDC, Microsoft released the <a href="http://www.codeplex.com/Silverlight">Silverlight Toolkit</a> a collection of Silverlight controls developers and designers can use in there Silverlight projects.  What is really cool about the way in which Shawn Burke&#8217;s team is working on control development, is this idea of releasing controls on Codeplex to get them quickly into the community.</p>
<p>If you play around with the toolkit you will quickly stumble on a new assembly called: &#8220;Microsoft.Windows.Controls.Theming&#8221;.  In a nut shell what this class does is give control developers access to the ability to theme their controls.  One of the key elements of this assembly is the &#8220;ImplicitStyleManager&#8221;.  This class exposes some attached properties that allow designers to specify an external resource file (.xaml) containing styles which can be applied to a control and each of the controls children.</p>
<p>Here is what i did to get my RatingControl to use the implicit style manager.  First I added a reference in my page.xaml to the Theming namespace.</p>

<div class="wp_syntax"><div class="code"><pre class="c-sharp" style="font-family:monospace;">xmlns:theming=&quot;clr-namespace:
Microsoft.Windows.Controls.Theming;
assembly=Microsoft.Windows.Controls.Theming&quot;</pre></div></div>

<p>Next I inserted a a few attributes into my rating control declaration to specify the location of my theme and how I wanted my theme applied.  I choose &#8220;Auto&#8221; which applies the theme immediately when the control is loaded.<br />
<a href="http://joel.neubeck.net/wp-content/uploads/2008/11/implicitstyle.png"><img class="alignleft size-full wp-image-303" title="implicitstyle" src="http://joel.neubeck.net/wp-content/uploads/2008/11/implicitstyle.png" alt="" width="500" height="89" /></a><br style="clear:both"/><br />
Lastly I copied my generic.xaml file into a new themes directory located in my test Silverlight project and renamed it to &#8220;themeA.xaml&#8221;.  Just to prove that the theme was loading I changed my RatingButton style to display an ellipse instead of the default star&#8217;s I had used in my original example.  Below is how it all turned out.</p>
<p><iframe src="/wp-content/uploads/2008/11/Rating/default.html" frameborder="0" width="300" height="300"></iframe>  </p>
<p>Code: <a onclick="javascript: pageTracker._trackPageview('/code/Rating2.zip');" href="/wp-content/uploads/2008/11/Rating/Rating.zip">Rating.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://joel.neubeck.net/2008/11/ratingcontrol-theme/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

