<?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>Designer Silverlight &#187; templates</title>
	<atom:link href="http://www.designersilverlight.com/category/templates/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.designersilverlight.com</link>
	<description>Matthias Shapiro's Silverlight &#38; WPF Blog - Because Developers Get All The Good Blogs</description>
	<lastBuildDate>Thu, 26 Jan 2012 06:45:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>New Silverlight Posts at Veracity Blogs</title>
		<link>http://www.designersilverlight.com/2009/08/19/new-silverlight-posts-at-veracity-blogs/</link>
		<comments>http://www.designersilverlight.com/2009/08/19/new-silverlight-posts-at-veracity-blogs/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 16:09:27 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[How To...]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[styles]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.designersilverlight.com/?p=732</guid>
		<description><![CDATA[I&#8217;ve started a series of posts on Silverlight and other topics over at the Veracity Solutions Blog. Veracity Solutions is the software consulting firm where I work and we&#8217;ve decided that it would be a good idea to do some sponsored posting there. Blog posts up so far are: Styling a ComboBox in Silverlight 3 [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started a series of posts on Silverlight and other topics over at the Veracity Solutions Blog.</p>
<p>Veracity Solutions is the software consulting firm where I work and we&#8217;ve decided that it would be a good idea to do some sponsored posting there.</p>
<p>Blog posts up so far are:</p>
<ul>
<li><a href="http://blogs.veracitysolutions.com/styling-a-combobox-in-silverlight-3/">Styling a ComboBox in Silverlight 3</a></li>
<li><a href="http://blogs.veracitysolutions.com/how-to-wrap-text-in-a-silverlight-3-combobox/">How To Wrap Text In a Silverlight 3 ComboBox</a></li>
<li><a href="http://blogs.veracitysolutions.com/how-to-get-a-silverlight-3-autocompletebox-to-show-sample-data-in-blend-3/">How To Get a Silverlight 3 AutoCompleteBox to Show Sample Data In Blend 3</a></li>
<li><a href="http://blogs.veracitysolutions.com/how-to-create-a-listbox-with-checkboxes-or-radiobuttons-in-silverlight-3/">How To Create A ListBox with CheckBoxes (or RadioButtons) In Silverlight 3</a></li>
</ul>
<p>More are coming, including tutorials on behaviors and paths.</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.designersilverlight.com/2009/08/19/new-silverlight-posts-at-veracity-blogs/&amp;layout=standard&amp;show_faces=1&amp;width=450&amp;action=like&amp;colorscheme=light&amp;font=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px"></iframe><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=New+Silverlight+Posts+at+Veracity+Blogs+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D732" title="Post to Twitter"><img class="nothumb" src="http://www.designersilverlight.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=New+Silverlight+Posts+at+Veracity+Blogs+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D732" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.designersilverlight.com/2009/08/19/new-silverlight-posts-at-veracity-blogs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Create An Animated ScrollViewer (or ListBox) in WPF</title>
		<link>http://www.designersilverlight.com/2009/05/06/how-to-create-an-animated-scrollviewer-or-listbox-in-wpf/</link>
		<comments>http://www.designersilverlight.com/2009/05/06/how-to-create-an-animated-scrollviewer-or-listbox-in-wpf/#comments</comments>
		<pubDate>Wed, 06 May 2009 22:38:53 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[Advanced Tutorial]]></category>
		<category><![CDATA[Binding]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[How To...]]></category>
		<category><![CDATA[ScrollViewer]]></category>
		<category><![CDATA[styles]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.designersilverlight.com/2009/05/06/how-to-create-an-animated-scrollviewer-or-listbox-in-wpf/</guid>
		<description><![CDATA[UPDATED 05/22/09 In the comments, someone mentioned that the project wasn&#8217;t working properly for keyed scrolling. I&#8217;ve updated the project with: Key scrolling (left, right, up, down, page up, page down) CanKeyboardScroll property on the AnimatedScrollViewer so that keyboard scrolling can be turned off ScrollToSelectedItem property on the AnimatedListBox so that the user can have [...]]]></description>
			<content:encoded><![CDATA[<p><b>UPDATED 05/22/09</b></p>
<p>In the comments, someone mentioned that the project wasn&#8217;t working properly for keyed scrolling. I&#8217;ve updated the project with:</p>
<ul>
<li>Key scrolling (left, right, up, down, page up, page down)</li>
<li>CanKeyboardScroll property on the AnimatedScrollViewer so that keyboard scrolling can be turned off</li>
<li>ScrollToSelectedItem property on the AnimatedListBox so that the user can have it automatically scroll to a ListBoxItem</li>
</ul>
<p>That last one is a little hacky&#8230; I use the ListBox ItemContainerGenerator to get the heights of all the items up to the one you want and then scroll it that. I&#8217;m almost positive there is a better way and if anyone knows what it is, I&#8217;d love to hear it. </p>
<p>First things first, here are the project files. </p>
<p><a href='http://www.designersilverlight.com/wp-content/uploads/2009/05/animatedscrollviewersource.zip'>Animated ScrollViewer and ListBox Project Files (Updated 5/22/09)</a> – Contains the AnimatedScrollViewer control library with AnimatedScrollViewer and AnimatedListBox</p>
<p><a href='http://www.designersilverlight.com/wp-content/uploads/2009/05/animatedscrollviewerdll.zip'>Animated ScrollViewer and ListBox DLL (Updated 5/22/09)</a> – For those of you who don’t care how it works and just want it to work</p>
<p>OK… this is going to be something of a whirlwind since I’ve never written a post this in-depth before… it will strain the limits of my ADD. </p>
<h3>Problem:</h3>
<p>The Listbox/ScrollViewer not only doesn’t animate, but it seems impossible to tweak it so that it animates.</p>
<h3>The Reason:</h3>
<p>The reason has everything to do with the ScrollViewer. Basically, the ScrollContainer and the ScrollBars are very tightly intertwined. There is a lot of code that does all the scrolling calculations and that code needs to apply to the scrolled content as well as the UI for the ScrollBars. If you dig deep enough, you’ll see the reasons. Reasons which I assume for the moment you don’t care about… you’re probably in more of a “make the @#&amp;($ thing work!” mood. I know I was.</p>
<h3>The Solution:</h3>
<p>My solution was basically to completely bypass the built-in ScrollBars and put in new ScrollBars with new logic. They look and act just like normal ScrollBars, so you should be able to style them just you would any normal ScrollViewer.</p>
<p>OK… how I did it. (I’m going to use both Blend 2 and Visual Studio 2008)</p>
<p>First, create a new custom control for WPF. This can be done by going into Visual Studio and creating a new Project. Select “WPF Custom Control Library”</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2009/05/clip-image0017.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image001[7]" border="0" alt="clip_image001[7]" src="http://www.designersilverlight.com/wp-content/uploads/2009/05/clip-image0017-thumb.png" width="498" height="163" /></a></p>
<p> In Blend: </p>
<p>&#160;<a href="http://www.designersilverlight.com/wp-content/uploads/2009/05/clip-image0019.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image001[9]" border="0" alt="clip_image001[9]" src="http://www.designersilverlight.com/wp-content/uploads/2009/05/clip-image0019-thumb.png" width="492" height="321" /></a></p>
<p> Add a WPF application to the project too so you have something to test. In the WPF application, get Blend to generate the default template for a normal ScrollViewer, accessible (in Blend) by putting a ScrollViewer into the project and right-clicking on it and selecting “Edit Control Parts (Template) –&gt; Edit a Copy…” </p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2009/05/clip-image001.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image001" border="0" alt="clip_image001" src="http://www.designersilverlight.com/wp-content/uploads/2009/05/clip-image001-thumb.png" width="323" height="96" /></a></p>
<p>Once have the default ScrollViewer template, select the “PART_VerticalScrollBar” and the “PART_HorizontalScrollBar” and copy and paste them. Rename your new ScrollBars something you like… I used “PART_AniVerticalScrollBar” and “PART&quot;_AniHorizontalScrollBar”. Now, set the Visibility of the original ScrollBars to “Collapsed”. (We can’t get rid of them, because the ScrollViewer will be looking for them and will throw a conniption if it can’t find them.) </p>
<p>Also, change the Value of your new ScrollBars to 0. You’ll probably have to click on the orange box next to Value and select “Reset”.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2009/05/clip-image00111.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image001[11]" border="0" alt="clip_image001[11]" src="http://www.designersilverlight.com/wp-content/uploads/2009/05/clip-image00111-thumb.png" width="219" height="66" /></a></p>
<p>In Visual Studio, right-click on your WPF Custom Control project and go to “Add –&gt; New Item…” . Then select “Custom Control (WPF)” and name it something you like (mine is named AnimatedScrollViewer). This should add a class to your project as well as a basic template to your Generic.xaml file.</p>
<p>Copy the ScrollViewer template that we just made and paste it into the Generic.xaml. The only change we need to make is to change:</p>
<p><span style="color: red">TargetType</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">x</span><span style="color: blue">:</span><span style="color: #a31515">Type </span><span style="color: red">ScrollViewer</span><span style="color: blue">}&quot;</span></p>
<p> <a href="http://11011.net/software/vspaste"></a>
<p>to</p>
<p><span style="color: red">TargetType</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">x</span><span style="color: blue">:</span><span style="color: #a31515">Type </span><span style="color: red">local</span><span style="color: blue">:</span><span style="color: red">AnimatedScrollViewer</span><span style="color: blue">}&quot;</span></p>
<p>in the Style and the ControlTemplate.</p>
<p>OK… that’s pretty much it with the XAML. Now we get to move into the code.</p>
<p>Right now, our class inherits from Control, but we want it to inherit from ScrollViewer like so:</p>
<p><span style="color: blue">public class </span><span style="color: #2b91af">AnimatedScrollViewer </span>: <span style="color: #2b91af">ScrollViewer</span></p>
<p> <a href="http://11011.net/software/vspaste"></a>
<p>Next get some containers for our new spiffy ScrollBars so that we can access them from the custom control code. Type the following before the class:</p>
<p>[<span style="color: #2b91af">TemplatePart</span>(Name = <span style="color: #a31515">&quot;PART_AniVerticalScrollBar&quot;</span>, Type = <span style="color: blue">typeof</span>(<span style="color: #2b91af">ScrollBar</span>))]     <br />[<span style="color: #2b91af">TemplatePart</span>(Name = <span style="color: #a31515">&quot;PART_AniHorizontalScrollBar&quot;</span>, Type = <span style="color: blue">typeof</span>(<span style="color: #2b91af">ScrollBar</span>))]</p>
<p>and the following just inside the class:</p>
<p><span style="color: #2b91af">ScrollBar </span>_aniVerticalScrollBar;     <br /><span style="color: #2b91af">ScrollBar </span>_aniHorizontalScrollBar;</p>
<p> <a href="http://11011.net/software/vspaste"></a>
<p>Now, we’ll override the OnApplyTemplate and make the connection between the template scrollBars and our class ScrollBars:</p>
<p><span style="color: blue">public override void</span>OnApplyTemplate()    <br />{    <br />&#160;&#160;&#160; <span style="color: blue">base</span>.OnApplyTemplate();    </p>
<p>&#160;&#160;&#160; <span style="color: #2b91af">ScrollBar </span>aniVScroll = <span style="color: blue">base</span>.GetTemplateChild(<span style="color: #a31515">&quot;PART_AniVerticalScrollBar&quot;</span>) <span style="color: blue">as</span><span style="color: #2b91af">ScrollBar</span>;    <br />&#160;&#160;&#160; <span style="color: blue">if</span>(aniVScroll != <span style="color: blue">null</span>)    <br />&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; _aniVerticalScrollBar = aniVScroll;    <br />&#160;&#160;&#160; }    <br />&#160;&#160;&#160; _aniVerticalScrollBar.ValueChanged += <span style="color: blue">new</span><span style="color: #2b91af">RoutedPropertyChangedEventHandler</span>&lt;<span style="color: blue">double</span>&gt;(_aniVerticalScrollBar_ValueChanged);    </p>
<p>&#160;&#160;&#160; <span style="color: #2b91af">ScrollBar </span>aniHScroll = <span style="color: blue">base</span>.GetTemplateChild(<span style="color: #a31515">&quot;PART_AniHorizontalScrollBar&quot;</span>) <span style="color: blue">as</span><span style="color: #2b91af">ScrollBar</span>;    <br />&#160;&#160;&#160; <span style="color: blue">if</span>(aniHScroll != <span style="color: blue">null</span>)    <br />&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; _aniHorizontalScrollBar = aniHScroll;    <br />&#160;&#160;&#160; }    <br />&#160;&#160;&#160; _aniHorizontalScrollBar.ValueChanged += <span style="color: blue">new</span><span style="color: #2b91af">RoutedPropertyChangedEventHandler</span>&lt;<span style="color: blue">double</span>&gt;(_aniHorizontalScrollBar_ValueChanged);    </p>
<p>&#160;&#160;&#160; <span style="color: blue">this</span>.PreviewMouseWheel += <span style="color: blue">new</span><span style="color: #2b91af">MouseWheelEventHandler</span>(AnimatedScrollViewer_PreviewMouseWheel);    <br />}<a href="http://11011.net/software/vspaste"></a></p>
<p>Before we address the three event handlers we added, we need to create the Dependency Properties with which they will be futzing.</p>
<p>(We’re going start going a little bit faster. Please download the code for the excruciating detail.) We need to add the following Dependency Properties. I’m using a “PropertyName (type)”. </p>
<h3>Dependency Properties</h3>
<p><strong>ScrollingTime (TimeSpan)</strong> – This will be an easy way to change the speed of the scrolling. I created mine to default at half a second, but if you changed it to 0 seconds, it would act just like any normal ScrollViewer.</p>
<p><strong>ScrollingSpline (KeySpline)</strong> – This property along with the ScrollingTime property is meant to give designers and developers the easiest control possible over the animation. This property describes the spline along which the scrolling will animate. If you don’t know what this means, just leave it alone, you’ll be fine. </p>
<p><strong>TargetVerticalOffset (double)</strong> and <strong>TargetHorizontalOffset (double)</strong> – These are properties that tell the ScrollViewer where it will be animating to. In the PropertyChangedCallback, they kick off a method that starts the animation.</p>
<p><strong>VerticalScrollOffset (double)</strong> and <strong>HorizontalScrollOffset (double)</strong> – For some reason the normal VerticalOffset and HorizontalOffset properties in a ScrollViewer are not capable of animation. So I wrote these properties that can be animated using standard storyboard procedures. If you use them to animate, make sure you also change the TargetVerticalOffset and TargetHorizontalOffset stuff as well… otherwise there will be a disconnect between the two. </p>
<h3>Event Handlers</h3>
<p><strong>CustomPreviewMouseWheel</strong> event handler – This grabs any mouse wheel spinning and uses it to change the TargetVerticalOffset so that the ScrollViewer will still animate the scrolling when the mouse wheel spins.</p>
<p><strong>VScrollBar_ValueChanged</strong> and <strong>HScrollBar_ValueChanged</strong> event handlers – These are called whenever the the ScrollBars are interacted with. There was a really weird problem with some of the interaction (the arrow keys and fast-scrolling buttons weren’t working properly), so these handlers hold logic to try to translate the weirdness into something viable. They then set the Target_Offset properties appropriately.</p>
<h3>Methods</h3>
<p><strong>animateScroller</strong> – This method builds the animation programmatically based off of the appropriate properties and runs it. </p>
<p> And that’s really about it. Once you have the AnimatedScrollViewer working, you can just add use it inside your ListBox templates and it should work. (For those who are averse to doing such a thing, I’ve added extremely simple AnimatedListBox.) </p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.designersilverlight.com/2009/05/06/how-to-create-an-animated-scrollviewer-or-listbox-in-wpf/&amp;layout=standard&amp;show_faces=1&amp;width=450&amp;action=like&amp;colorscheme=light&amp;font=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px"></iframe><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=How+To+Create+An+Animated+ScrollViewer+%28or+ListBox%29+in+WPF+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D653" title="Post to Twitter"><img class="nothumb" src="http://www.designersilverlight.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=How+To+Create+An+Animated+ScrollViewer+%28or+ListBox%29+in+WPF+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D653" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.designersilverlight.com/2009/05/06/how-to-create-an-animated-scrollviewer-or-listbox-in-wpf/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Silverlight 2 Resources Browser (works with RC0)</title>
		<link>http://www.designersilverlight.com/2008/10/03/silverlight-2-resources-browser-works-with-rc0/</link>
		<comments>http://www.designersilverlight.com/2008/10/03/silverlight-2-resources-browser-works-with-rc0/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 18:15:19 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://www.designersilverlight.com/2008/10/03/silverlight-2-resources-browser-works-with-rc0/</guid>
		<description><![CDATA[David Anson has put up a pretty cool application for looking at the default templates for Silverlight 2 controls. It works with Silverlight 2 RC0, which was released just this last week. This is pretty freaking awesome stuff for anyone doing design in Silverlight.  Go check it out. A note: I would comment more about [...]]]></description>
			<content:encoded><![CDATA[<p>David Anson has <a href="http://blogs.msdn.com/delay/archive/2008/09/26/preserving-access-to-silverlight-2-s-generic-xaml-resources-silverlightdefaultstylebrowser-updated-for-the-silverlight-2-rc.aspx">put up a pretty cool application for looking at the default templates for Silverlight 2 controls</a>. It works with Silverlight 2 RC0, which was released just this last week.</p>
<p>This is pretty freaking awesome stuff for anyone doing design in Silverlight.  Go check it out.</p>
<p>A note: I would comment more about RC0 except that I&#8217;m doing alot of work with Silverlight that needs to be working with today&#8217;s plugins and it is my understanding that RC0 stuff may not work with the current plugin. If I&#8217;ve misunderstood, someone correct me please.</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.designersilverlight.com/2008/10/03/silverlight-2-resources-browser-works-with-rc0/&amp;layout=standard&amp;show_faces=1&amp;width=450&amp;action=like&amp;colorscheme=light&amp;font=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px"></iframe><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Silverlight+2+Resources+Browser+%28works+with+RC0%29+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D366" title="Post to Twitter"><img class="nothumb" src="http://www.designersilverlight.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Silverlight+2+Resources+Browser+%28works+with+RC0%29+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D366" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.designersilverlight.com/2008/10/03/silverlight-2-resources-browser-works-with-rc0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To Use a ListView or DataGrid In a ComboBox Drop Down (Without A Line Of Code)</title>
		<link>http://www.designersilverlight.com/2008/10/01/how-to-use-a-listview-or-datagrid-in-a-combobox-drop-down-without-a-line-of-code/</link>
		<comments>http://www.designersilverlight.com/2008/10/01/how-to-use-a-listview-or-datagrid-in-a-combobox-drop-down-without-a-line-of-code/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 00:30:00 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[combobox]]></category>
		<category><![CDATA[listview]]></category>
		<category><![CDATA[styles]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.designersilverlight.com/2008/10/01/how-to-use-a-listview-or-datagrid-in-a-combobox-drop-down-without-a-line-of-code/</guid>
		<description><![CDATA[Super cool new thing I learned today. In WPF, we can make it so that the drop down (popup) on a ComboBox displays the data in a ListView. Because of the fact that I believe the DataGrid will eventually overtake the ListView as the gold standard for data display in WPF, we’ll do it both [...]]]></description>
			<content:encoded><![CDATA[<p>Super cool new thing I learned today. In WPF, we can make it so that the drop down (popup) on a ComboBox displays the data in a ListView. Because of the fact that I believe the DataGrid will eventually overtake the ListView as the gold standard for data display in WPF, we’ll do it both ways.</p>
<p>This tutorial is done entirely in Blend and without a line of code.</p>
<p><strong>Step 0)</strong> (for the DataGrid only)</p>
<p>Go to Code Plex and <a href="http://www.codeplex.com/wpf/Release/ProjectReleases.aspx?ReleaseId=14963">download the WPF Toolkit</a>. Extract to a convenient location.</p>
<p>Right-Click on the References folder in your project tab and click “Add Reference…”</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image001.png"><img src="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image001-thumb.png" title="clip_image001" style="border-width: 0px; display: inline" alt="clip_image001" border="0" height="85" width="238" /></a></p>
<p>Navigate to the location you extracted the WPFToolkit.dll file, select it and hit OK.<br />
<a href="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image0016.png"><img src="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image0016-thumb.png" title="clip_image001[6]" style="border-width: 0px; display: inline" alt="clip_image001[6]" border="0" height="205" width="177" /></a></p>
<p>Step 1) Select the ComboBox you wish to change and edit the ControlTemplate by right-clicking and selecting “Edit Control Parts (Template) –&gt; Edit a Copy…”</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image0011.png"><img src="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image0011-thumb.png" title="clip_image001[1]" style="border: 0px none ; display: inline" alt="clip_image001[1]" border="0" height="55" width="328" /></a></p>
<p>Step 2) Find the ItemsPresenter. This is what would normally display our ItemsSource.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image0013.png"><img src="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image0013-thumb.png" title="clip_image001[3]" style="border: 0px none ; display: inline" alt="clip_image001[3]" border="0" height="187" width="252" /></a></p>
<p>We’re going to get rid of it. And the ScrollViewer for good measure.</p>
<p>Step 3) Where the ScrollViewer is, put in a ListView or a DataGrid, whichever one you’re using.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image0015.png"><img src="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image0015-thumb.png" title="clip_image001[5]" style="border: 0px none ; display: inline" alt="clip_image001[5]" border="0" height="132" width="255" /></a></p>
<p>Now, go the properties of that ListView or DataGrid and click on the box to the right of “ItemsSource”</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image00111.png"><img src="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image00111-thumb.png" title="clip_image001[11]" style="border: 0px none ; display: inline" alt="clip_image001[11]" border="0" height="60" width="168" /></a></p>
<p>and, in the resulting menu, select “Template Binding –&gt; ItemsSource”.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image0017.png"><img src="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image0017-thumb.png" title="clip_image001[7]" style="border: 0px none ; display: inline" alt="clip_image001[7]" border="0" height="294" width="438" /></a></p>
<p>Set the DataContext of the ListView or DataGrid to the DataContext of the parent ComboBox using the same process.</p>
<p>And… you’re done! Open the ComboBox and you will see that you can select items in the ListView or DataGrid in the ComboBox dropdown and see those items change the selection of the ComboBox.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image00113.png"><img src="http://www.designersilverlight.com/wp-content/uploads/2008/10/clip-image00113-thumb.png" title="clip_image001[13]" style="border: 0px none ; display: inline" alt="clip_image001[13]" border="0" height="193" width="545" /></a></p>
<p>You’ll notice that this is probably not yet an ideal solution. For example, when we select an item, the dropdown doesn’t automatically close. Your best bet is to use the SelectionChanged event to trigger some logic to close the ComboBox dropdown.</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.designersilverlight.com/2008/10/01/how-to-use-a-listview-or-datagrid-in-a-combobox-drop-down-without-a-line-of-code/&amp;layout=standard&amp;show_faces=1&amp;width=450&amp;action=like&amp;colorscheme=light&amp;font=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px"></iframe><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=How+To+Use+a+ListView+or+DataGrid+In+a+ComboBox+Drop+Down+%28Without+A+Line+Of+Code%29+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D365" title="Post to Twitter"><img class="nothumb" src="http://www.designersilverlight.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=How+To+Use+a+ListView+or+DataGrid+In+a+ComboBox+Drop+Down+%28Without+A+Line+Of+Code%29+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D365" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.designersilverlight.com/2008/10/01/how-to-use-a-listview-or-datagrid-in-a-combobox-drop-down-without-a-line-of-code/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Create a Zooming Button Style In Silverlight Without Code</title>
		<link>http://www.designersilverlight.com/2008/09/19/create-a-zooming-button-style-in-silverlight-without-code/</link>
		<comments>http://www.designersilverlight.com/2008/09/19/create-a-zooming-button-style-in-silverlight-without-code/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 14:29:37 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[Blend]]></category>
		<category><![CDATA[Helpful Links]]></category>
		<category><![CDATA[How To...]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[styles]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.designersilverlight.com/2008/09/19/create-a-zooming-button-style-in-silverlight-without-code/</guid>
		<description><![CDATA[Download code for this sample (updated for RCW) I was reading Mike Snow&#8217;s blog and he had a recent Silverlight tutorial on creating a Zooming toolbar. I looked at it and said to myself, &#8220;I think I can do that without code in Blend!&#8221; So here&#8217;s a tutorial on exactly that. End product : Big [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.designersilverlight.com/wp-content/uploads/2008/11/rcw_zooming_button.zip'>Download code for this sample (updated for RCW)</a></p>
<p>I was reading Mike Snow&#8217;s blog and he had a recent <a href="http://silverlight.net/blogs/msnow/archive/2008/09/10/silverlight-tip-of-the-day-39-how-to-create-a-zoom-toolbar.aspx">Silverlight tutorial on creating a Zooming toolbar</a>. I looked at it and said to myself, &#8220;I think I can do that without code in Blend!&#8221; So here&#8217;s a tutorial on exactly that.</p>
<p>End product :</p>
<p><iframe src="http://silverlight.services.live.com/invoke/77530/ZoomBtnRCW/iframe.html" scrolling="no" frameborder="0" style="width:450px; height:400px"></iframe></p>
<p>Big bonuses to this XAML-only method include:</p>
<ul>
<li>Much smoother animation</li>
<li>Midway animation (if you fly over a button, it doesn&#8217;t need to animate all the way up before it starts to animate back down)</li>
<li>Really low overhead</li>
<li>Can be done and maintained entirely by a designer in Blend without any code</li>
</ul>
<p>1) create a new Silverlight project in either Visual Studio 2008 or Blend 2.5.</p>
<p>2) In Blend, add a new folder for our images by right-clicking on the project and selecting &#8220;Add New Folder&#8221;</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image001.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image001-thumb.png" border="0" alt="clip_image001" width="207" height="72" /></a></p>
<p>3) Pull in our images by right-clicking on our new folder and selecting &#8220;Add Existing Item&#8230;&#8221; Navigate to the images you want to use and select &#8220;OK&#8221; to bring them into the project.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image0014.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image0014-thumb.png" border="0" alt="clip_image001[4]" width="273" height="63" /></a></p>
<p>4) Create the button to which you want to add the image and then double-click it in the Obejcts and Timeline pane so that it has a yellow outline around it.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image0016.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image0016-thumb.png" border="0" alt="clip_image001[6]" width="314" height="180" /></a></p>
<p>5) Now, go to the image you want to insert (in the Project panel), right click on it and select &#8220;Insert&#8221;</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image0018.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image0018-thumb.png" border="0" alt="clip_image001[8]" width="317" height="188" /></a></p>
<p>OK&#8230; so now we have a button with an image in it. Now it&#8217;s time to make the sucker zoom.</p>
<p>6) Right click on the button and select &#8220;Edit Control Parts (Template) -&gt; Edit a Copy&#8230;&#8221;</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00110.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00110-thumb.png" border="0" alt="clip_image001[10]" width="338" height="86" /></a></p>
<p>Name your custom Template and hit OK</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00112.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00112-thumb.png" border="0" alt="clip_image001[12]" width="382" height="88" /></a></p>
<p>7) In the &#8220;States&#8221; pane, you see a set of &#8220;CommonStates&#8221; (Normal, MouseOver, Pressed, and Disabled). Click on the MouseOver state and a red box will surround your composition, indicating that any changes made will be changes to the &#8220;Mouse Over&#8221; state, not to the default control.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00114.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00114-thumb.png" border="0" alt="clip_image001[14]" width="255" height="156" /></a></p>
<p>Recording state:</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00116.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00116-thumb.png" border="0" alt="clip_image001[16]" width="160" height="40" /></a></p>
<p>8] Click on the highest level item in the template (in my case, it is a &#8220;Grid&#8221;) and go to the &#8220;Transform&#8221; section in the &#8220;Properties&#8221; pane and select the &#8220;Scale&#8221; transformation tab. Change the X and Y scales to &#8220;1.5&#8243;</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00118.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00118-thumb.png" border="0" alt="clip_image001[18]" width="281" height="309" /></a></p>
<p>If you run the project now, you&#8217;ll notice that we get a cool zoom in effect on the mouse over, but our zoom out when the mouse leaves the button is basically a snap back to the original size. Let&#8217;s fix that now.</p>
<p>9) Click on the the arrow icon in the MouseOver state in the States pane and select the &#8220;MouseOver -&gt; Normal&#8221;</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00120.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00120-thumb.png" border="0" alt="clip_image001[20]" width="380" height="109" /></a></p>
<p>In the &#8220;Transition Duration&#8221; box, type &#8220;.2&#8243;</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00124.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00124-thumb.png" border="0" alt="clip_image001[24]" width="243" height="74" /></a></p>
<p>10) Extra Designer Happiness Bonus Step! &#8211; If you&#8217;d like to have a zoom effect that isn&#8217;t strictly linear, open up the timeline view with the button on the right hand of the state recording box (seen below).</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00126.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00126-thumb.png" border="0" alt="clip_image001[26]" width="255" height="54" /></a></p>
<p>Click and drag the keyframe (the light gray oval below) to the point you want it. I put mine at .3 seconds.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00128.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00128-thumb.png" border="0" alt="clip_image001[28]" width="276" height="136" /></a></p>
<p>With the keyframe selected, you should see an &#8220;Easing&#8221; pane on the right. The default easing is linear (aka. no easing), but you can change the easing curve by just dragging the yellow dots. Here is the easing curve I&#8217;ve found works pretty well for my apps.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00130.png"><img style="border-width: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/09/clip-image00130-thumb.png" border="0" alt="clip_image001[30]" width="282" height="326" /></a></p>
<p>That&#8217;s it. Now you can just assign this template to a button and you&#8217;ll have this zooming functionality all set up.<a href="http://www.designersilverlight.com/wp-content/uploads/2008/11/rcw_zooming_button.xap">rcw_zooming_button</a></p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.designersilverlight.com/2008/09/19/create-a-zooming-button-style-in-silverlight-without-code/&amp;layout=standard&amp;show_faces=1&amp;width=450&amp;action=like&amp;colorscheme=light&amp;font=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px"></iframe><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Create+a+Zooming+Button+Style+In+Silverlight+Without+Code+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D331" title="Post to Twitter"><img class="nothumb" src="http://www.designersilverlight.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Create+a+Zooming+Button+Style+In+Silverlight+Without+Code+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D331" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.designersilverlight.com/2008/09/19/create-a-zooming-button-style-in-silverlight-without-code/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Styling a Silverlight ScrollViewer (to Look Like a Mac ScrollViewer)</title>
		<link>http://www.designersilverlight.com/2008/08/26/styling-a-silverlight-scrollviewer-to-look-like-a-mac-scrollviewer/</link>
		<comments>http://www.designersilverlight.com/2008/08/26/styling-a-silverlight-scrollviewer-to-look-like-a-mac-scrollviewer/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 04:04:47 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[ScrollViewer]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[styles]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.designersilverlight.com/2008/08/26/styling-a-silverlight-scrollviewer-to-look-like-a-mac-scrollviewer/</guid>
		<description><![CDATA[Mac Scroller Project Files Updated for RCW Just because we&#8217;re working in Microsoft technologies doesn&#8217;t mean we can&#8217;t throw a bone to our Mac friends. After all, they are the people we love, our cousins and our neighbors, and that irritating guy who is dating our daughter and can&#8217;t seem to shut up about how [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.designersilverlight.com/wp-content/uploads/2008/11/update_macscroller.zip'>Mac Scroller Project Files Updated for RCW</a></p>
<p>Just because we&#8217;re working in Microsoft technologies doesn&#8217;t mean we can&#8217;t throw a bone to our Mac friends. After all, they are the people we love, our cousins and our neighbors, and that irritating guy who is dating our daughter and can&#8217;t seem to shut up about how awesome his Mac is even though he&#8217;ll be long out of his program in musical costume design before he ever pays off his laptop &#8230;</p>
<p>Issues? I don&#8217;t have issues. Why do you ask?</p>
<p>Anyway, since Silverlight is a semi-ubiquitous technology, it would be nice if we could cater to all platforms and not make anyone feel left out. And nothing makes people feel more left out than when they expect their application to work one way and it doesn&#8217;t.</p>
<p>So, here&#8217;s a picture of what we&#8217;re going for.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image0012.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image001-thumb1.png" border="0" alt="clip_image001" width="181" height="156" /></a></p>
<p>As far as I&#8217;m concerned (and therefore as far as this tutorial is concerned) the important stuff is to make sure that the incremental buttons (the arrow buttons in the bottom right) are in the right place. We can deal with the color later.</p>
<p>OK, so let create our ScrollViewer (I&#8217;ll be using Blend exclusively for this). I tossed a button in it and made it small so we can see both of the ScrollBars.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image0014.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image0014-thumb.png" border="0" alt="clip_image001[4]" width="213" height="160" /></a></p>
<p>Right click on the ScrollViewer in the &#8220;Objects and Timeline&#8221; section and go down to &#8220;Edit Control Parts (Template) -&gt; Edit a Copy&#8230;&#8221;</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image0016.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image0016-thumb.png" border="0" alt="clip_image001[6]" width="330" height="101" /></a></p>
<p>You should have something that looks like this:</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image0018.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image0018-thumb.png" border="0" alt="clip_image001[8]" width="249" height="149" /></a></p>
<p>Let&#8217;s do the VerticalScrollBar first. Right click on it and go to &#8220;Edit Control Parts (Template) -&gt; Edit a Copy&#8230;&#8221; Name it something memorable and you should get something like this:</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image001121.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00112-thumb1.png" border="0" alt="clip_image001[12]" width="254" height="252" /></a></p>
<p>This is actually easier than it looks. The unnamed rectangles and the path lay down the basic visual backbone for the ScrollBar and the rest of it runs like this:<br />
<a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image001141.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00114-thumb1.png" border="0" alt="clip_image001[14]" width="45" height="37" /></a><br />
VerticalSmallDecrease &#8211; The up button<br />
VerticalLargeDecrease &#8211; The space between the up button and the VerticalThumb<br />
<a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00116.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00116-thumb1.png" border="0" alt="clip_image001[16]" width="45" height="104" /></a><br />
VerticalThumb &#8211; The interface element that allows the dragging interaction of the scrollbar<br />
VerticalLargeIncrease &#8211; The space between the down button and the VerticalThumb<br />
<a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image001181.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00118-thumb1.png" border="0" alt="clip_image001[18]" width="46" height="30" /></a><br />
VerticalSmallIncrease &#8211; The down button</p>
<p>The horizontal root in this template is strikingly similar.</p>
<p>So, let&#8217;s start by moving the VerticalSmallDecrease button down to the bottom above the VerticalSmallIncrease button. The magic here will happen in the VerticalRoot grid. (I highly recommend the Design/XAML split view for this one.) In the design view, our grid looks like this:</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image001201.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00120-thumb1.png" border="0" alt="clip_image001[20]" width="103" height="277" /></a></p>
<p>Ugly. However, in the XAML, it looks like this:</p>
<p><span style="color: blue;">&lt;</span><span style="color: #a31515;">Grid.RowDefinitions</span><span style="color: blue;">&gt;<br />
&lt;</span><span style="color: #a31515;">RowDefinition </span><span style="color: red;">Height</span><span style="color: blue;">=&#8221;Auto&#8221;/&gt;<br />
</span> <span style="color: blue;">&lt;</span><span style="color: #a31515;">RowDefinition </span><span style="color: red;">Height</span><span style="color: blue;">=&#8221;Auto&#8221;/&gt;<br />
&lt;</span><span style="color: #a31515;">RowDefinition </span><span style="color: red;">Height</span><span style="color: blue;">=&#8221;Auto&#8221;/&gt;<br />
&lt;</span><span style="color: #a31515;">RowDefinition </span><span style="color: red;">Height</span><span style="color: blue;">=&#8221;*&#8221;/&gt;<br />
&lt;</span><span style="color: #a31515;">RowDefinition </span><span style="color: red;">Height</span><span style="color: blue;">=&#8221;Auto&#8221;/&gt;<br />
&lt;/</span><span style="color: #a31515;">Grid.RowDefinitions</span><span style="color: blue;">&gt;<br />
&lt;</span><span style="color: #a31515;">Grid.ColumnDefinitions</span><span style="color: blue;">&gt;<br />
&lt;</span><span style="color: #a31515;">ColumnDefinition</span><span style="color: blue;">/&gt;<br />
&lt;</span><span style="color: #a31515;">ColumnDefinition</span><span style="color: blue;">/&gt;<br />
&lt;/</span><span style="color: #a31515;">Grid.ColumnDefinitions</span><span style="color: blue;">&gt;</span></p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Much easier. For the purposes of maintaining a coherent structure, drag the VerticalSmallDecrease in Objects and Timeline pane until it is between the VerticalSmallIncrease and the VerticalLargeIncrease. Next, change the third RowDefinition to &#8220;*&#8221;. You can do this in the XAML or by clicking on the &#8220;Auto&#8221; icon<a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/image.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/image-thumb.png" border="0" alt="image" width="19" height="18" /></a> until it becomes a &#8220;*&#8221; icon. <a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/image1.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/image-thumb1.png" border="0" alt="image" width="22" height="19" /></a> Change the fourth RowDefinition from &#8220;*&#8221; to &#8220;Auto&#8221;. When you do this, it won&#8217;t immediately act like an &#8220;Auto&#8221;. This is because Blend gives it an automatic &#8220;MinHeight&#8221; of whatever the current Height is. You can change that in the XAML (easiest move) or you can highlight that row by clicking just below the &#8220;Auto&#8221; icon until the row highlights in a semitransparent gray like so.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image001281.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00128-thumb1.png" border="0" alt="clip_image001[28]" width="90" height="82" /></a></p>
<p>You may need to zoom in to do this. Once highlighted, the properties of the Row will show up in the Properties tab on the right. Change the MinHeight to 0.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00132.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00132-thumb.png" border="0" alt="clip_image001[32]" width="286" height="128" /></a></p>
<p>Now we&#8217;ll need to change the Grid.Row properties of almost everything. Click on the items in the Objects and Timeline and change the Row property in the Layout section of the Properties tab like so:</p>
<p>VerticalLargeDecrease -&gt; Row = 0<br />
VerticalThumb -&gt; Row = 1<br />
VerticalLargeIncrease -&gt; Row = 2<br />
VerticalSmallDecrease -&gt; Row = 3<br />
VerticalSmallIncrease -&gt; Row = 4</p>
<p>You&#8217;re done. With the Vertical part of the ScrollBar at least. You can do the same thing with the Horizontal part of it. Just move around the buttons, change the ColumnDefinitions and update the Column assignments. My best recommendation is to go back to the ScrollViewer template and assign your new ScrollBar template to the HorizontalScrollBar and then go back to editing the template from there.</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00134.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00134-thumb.png" border="0" alt="clip_image001[34]" width="447" height="118" /></a></p>
<h2>Later on&#8230;</h2>
<p>After a bunch of color tweaking, I have a scroll viewer in silverlight that looks like this:</p>
<p><a href="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00136.png"><img style="border: 0px" src="http://www.designersilverlight.com/wp-content/uploads/2008/08/clip-image00136-thumb.png" border="0" alt="clip_image001[36]" width="44" height="246" /></a></p>
<p>I&#8217;m feeling OK with it. I&#8217;ve embedded what I have at this point below.</p>
<p><iframe src="http://silverlight.services.live.com/invoke/77530/RCW_MacScrollBar/iframe.html" scrolling="no" frameborder="0" style="width:400px; height:300px"></iframe></p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.designersilverlight.com/2008/08/26/styling-a-silverlight-scrollviewer-to-look-like-a-mac-scrollviewer/&amp;layout=standard&amp;show_faces=1&amp;width=450&amp;action=like&amp;colorscheme=light&amp;font=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px"></iframe><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Styling+a+Silverlight+ScrollViewer+%28to+Look+Like+a+Mac+ScrollViewer%29+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D296" title="Post to Twitter"><img class="nothumb" src="http://www.designersilverlight.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Styling+a+Silverlight+ScrollViewer+%28to+Look+Like+a+Mac+ScrollViewer%29+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D296" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.designersilverlight.com/2008/08/26/styling-a-silverlight-scrollviewer-to-look-like-a-mac-scrollviewer/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tip For Finding Resources for a Control in generic.xaml</title>
		<link>http://www.designersilverlight.com/2008/08/26/tip-for-finding-resources-for-a-control-in-genericxaml/</link>
		<comments>http://www.designersilverlight.com/2008/08/26/tip-for-finding-resources-for-a-control-in-genericxaml/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 00:39:42 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[Advanced Tutorial]]></category>
		<category><![CDATA[listview]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.designersilverlight.com/2008/08/26/tip-for-finding-resources-for-a-control-in-genericxaml/</guid>
		<description><![CDATA[I&#8217;ve recently be working on changing the ControlTemplate of a GridViewColumnHeader in a custom ListView that we&#8217;ve been working on. (The ListView was rewritten for sorting, so that&#8217;s why it had to be custom.) One of the things we had to do was swap out ControlTemplates so that we could display a caret to indicate [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently be working on changing the ControlTemplate of a GridViewColumnHeader in a custom ListView that we&#8217;ve been working on. (The ListView was rewritten for sorting, so that&#8217;s why it had to be custom.)</p>
<p>One of the things we had to do was swap out ControlTemplates so that we could display a caret to indicate ascending or descending lists. We ended up deciding on ControlTemplates over DataTemplates because the DataTemplates would only work for ListViews that had no custom DataTemplates for the headers. We&#8217;re doing all sorts of crazy stuff with our headers and we need to preserve our DataTemplates, so this wasn&#8217;t an option. </p>
<p>In any case, I was having no luck finding the resource when I named it this way:</p>
<blockquote><p><span style="color: blue">&lt;</span><span style="color: #a31515">ControlTemplate </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Key</span><span style="color: blue">=&quot;MyCustomControlTemplate&quot; <span style="color: red">TargetType</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">x</span><span style="color: blue">:</span><span style="color: #a31515">Type </span><span style="color: red">GridViewColumnHeader</span><span style="color: blue">}&quot;&gt;</span></span></p>
</blockquote>
<p> <a href="http://11011.net/software/vspaste"></a>
<p>I was using the following code to try and find the resource.</p>
<blockquote><p><span style="color: #2b91af">ControlTemplate </span>myNewTemplate = (<span style="color: #2b91af">ControlTemplate</span>)Resources[<span style="color: #a31515">&quot;MyCustomTemplate&quot;</span>];</p>
</blockquote>
<p> <a href="http://11011.net/software/vspaste"></a>
<p>However, we were able to solve the problem by naming the resource this way</p>
<blockquote><p><span style="color: blue">&lt;</span><span style="color: #a31515">ControlTemplate </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Key</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">ComponentResourceKey </span><span style="color: red">TypeInTargetAssembly</span><span style="color: blue">={</span><span style="color: #a31515">x</span><span style="color: blue">:</span><span style="color: #a31515">Type </span><span style="color: red">local</span><span style="color: blue">:</span><span style="color: red">MyCustomListView</span><span style="color: blue">}, </span><span style="color: red">ResourceId</span><span style="color: blue">=MyCustomControlTemplate}&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue"><span style="color: red">TargetType</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">x</span><span style="color: blue">:</span><span style="color: #a31515">Type </span><span style="color: red">GridViewColumnHeader</span><span style="color: blue">}&quot;&gt;</span></span></p>
<p>   <a href="http://11011.net/software/vspaste"></a></p></blockquote>
<p> <a href="http://11011.net/software/vspaste"></a>
<p>And then using this code to access it.</p>
<blockquote><p><span style="color: #2b91af">ComponentResourceKey </span>myCustomTemplateKey = <span style="color: blue">new </span><span style="color: #2b91af">ComponentResourceKey</span>(<span style="color: blue">typeof</span>(<span style="color: #2b91af">SortableListView</span>), <span style="color: #a31515">&quot;MyCustomControlTemplate&quot;</span>);      <br /><span style="color: #2b91af">ControlTemplate </span>myNewTemplate = (<span style="color: #2b91af">ControlTemplate</span>)<span style="color: blue">this</span>.TryFindResource(myCustomTemplateKey);</p>
</blockquote>
<p> <a href="http://11011.net/software/vspaste"></a>
<p>Just thought I&#8217;d pass it along.</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.designersilverlight.com/2008/08/26/tip-for-finding-resources-for-a-control-in-genericxaml/&amp;layout=standard&amp;show_faces=1&amp;width=450&amp;action=like&amp;colorscheme=light&amp;font=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px"></iframe><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Tip+For+Finding+Resources+for+a+Control+in+generic.xaml+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D267" title="Post to Twitter"><img class="nothumb" src="http://www.designersilverlight.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Tip+For+Finding+Resources+for+a+Control+in+generic.xaml+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D267" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.designersilverlight.com/2008/08/26/tip-for-finding-resources-for-a-control-in-genericxaml/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Assign ColumnHeaderContainerStyle and ColumnHeaderTemplate to a ListView Style</title>
		<link>http://www.designersilverlight.com/2008/08/15/how-to-assign-columnheadercontainerstyle-and-columnheadertemplate-to-a-listview-style/</link>
		<comments>http://www.designersilverlight.com/2008/08/15/how-to-assign-columnheadercontainerstyle-and-columnheadertemplate-to-a-listview-style/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 23:06:06 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[How To...]]></category>
		<category><![CDATA[listview]]></category>
		<category><![CDATA[styles]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML]]></category>
		<category><![CDATA[columnheadercontainerstyle]]></category>
		<category><![CDATA[columnheadertemplate]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[style]]></category>

		<guid isPermaLink="false">http://www.designersilverlight.com/2008/08/15/how-to-assign-columnheadercontainerstyle-and-columnheadertemplate-to-a-listview-style/</guid>
		<description><![CDATA[This is just a quick note on creating a ListView style with the appropriate GridView style and template assignments. Normally, I&#8217;ve been creating listviews that look like this: &#60;ListView x:Name=&#8221;MyListView&#8221;                ItemContainerStyle=&#8221;{DynamicResource MyListViewItemContainerStyle}&#8221;&#62;     &#60;ListView.View&#62;          &#60;GridView ColumnHeaderContainerStyle=&#8221;{DynamicResource MyListViewHeaderStyle}&#8221;                          ColumnHeaderTemplate=&#8221;{DynamicResource MyGridColumnHeaderTemplate}&#8221;&#62;  I did this because I didn&#8217;t know exactly how to assign these styles [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a quick note on creating a ListView style with the appropriate GridView style and template assignments.</p>
<p>Normally, I&#8217;ve been creating listviews that look like this:</p>
<blockquote>
<pre class="code"><span style="color: blue"></span></pre>
<p><span style="color: blue">&lt;</span><span style="color: #a31515">ListView </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&#8221;MyListView&#8221;</span><span style="color: red"><br />
               ItemContainerStyle</span><span style="color: blue">=&#8221;{</span><span style="color: #a31515">DynamicResource </span><span style="color: red">MyListViewItemContainerStyle</span><span style="color: blue">}&#8221;&gt;<br />
    </span><span style="color: blue">&lt;</span><span style="color: #a31515">ListView.View</span><span style="color: blue">&gt;<br />
         </span><span style="color: blue"><span style="color: blue">&lt;</span><span style="color: #a31515">GridView </span><span style="color: red">ColumnHeaderContainerStyle</span><span style="color: blue">=&#8221;{</span><span style="color: #a31515">DynamicResource </span><span style="color: red">MyListViewHeaderStyle</span><span style="color: blue">}&#8221;<br />
                         </span></span><span style="color: blue"><span style="color: red">ColumnHeaderTemplate</span><span style="color: blue">=&#8221;{</span><span style="color: #a31515">DynamicResource </span><span style="color: red">MyGridColumnHeaderTemplate</span><span style="color: blue">}&#8221;&gt;</span></span><span style="color: blue"> </span></p></blockquote>
<p><span style="color: blue"><font color="#000000">I did this because I didn&#8217;t know exactly how to assign these styles and templates to the ListView Style. In the style, ColumnHeaderContainerStyle and ColumnHeaderTemplate are not properties of the ListView, they are properties of the GridView&#8230; which you can&#8217;t create a style for.</font></span></p>
<p><span style="color: blue"><font color="#000000">Instead, you can encapsulate all the information above in the following style.</font></span></p>
<blockquote><p><span style="color: blue">&lt;</span><span style="color: #a31515">Style </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Key</span><span style="color: blue">=&#8221;CustomListViewStyle&#8221; </span><span style="color: red">TargetType</span><span style="color: blue">=&#8221;{</span><span style="color: #a31515">x</span><span style="color: blue">:</span><span style="color: #a31515">Type </span><span style="color: red">ListView</span><span style="color: blue">}&#8221;&gt;<br />
      &lt;</span><span style="color: #a31515">Setter </span><span style="color: red">Property</span><span style="color: blue">=&#8221;GridView.ColumnHeaderContainerStyle&#8221; </span><span style="color: red">Value</span><span style="color: blue">=&#8221;{</span><span style="color: #a31515">DynamicResource </span><span style="color: red">MyListViewHeaderStyle</span><span style="color: blue">}&#8221; /&gt;<br />
      </span><span style="color: blue">&lt;</span><span style="color: #a31515">Setter </span><span style="color: red">Property</span><span style="color: blue">=&#8221;GridView.ColumnHeaderTemplate&#8221; </span><span style="color: red">Value</span><span style="color: blue">=&#8221;{</span><span style="color: #a31515">DynamicResource </span><span style="color: red">MyGridColumnHeaderTemplate</span><span style="color: blue">}&#8221; /&gt;<br />
      </span><span style="color: blue">&lt;</span><span style="color: #a31515">Setter </span><span style="color: red">Property</span><span style="color: blue">=&#8221;ItemContainerStyle&#8221; </span><span style="color: red">Value</span><span style="color: blue">=&#8221;{</span><span style="color: #a31515">DynamicResource </span><span style="color: red">MyListViewItemContainerStyle</span><span style="color: blue">}&#8221; /&gt;<br />
<span style="color: blue">&lt;/</span><span style="color: #a31515">Style&gt;</span></span></p></blockquote>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><span style="color: blue"><font color="#000000">Problem solved.</font></span></p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.designersilverlight.com/2008/08/15/how-to-assign-columnheadercontainerstyle-and-columnheadertemplate-to-a-listview-style/&amp;layout=standard&amp;show_faces=1&amp;width=450&amp;action=like&amp;colorscheme=light&amp;font=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px"></iframe><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=How+to+Assign+ColumnHeaderContainerStyle+and+ColumnHeaderTemplate+to+a+ListView+Style+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D266" title="Post to Twitter"><img class="nothumb" src="http://www.designersilverlight.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=How+to+Assign+ColumnHeaderContainerStyle+and+ColumnHeaderTemplate+to+a+ListView+Style+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D266" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.designersilverlight.com/2008/08/15/how-to-assign-columnheadercontainerstyle-and-columnheadertemplate-to-a-listview-style/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WPF Designers Guide to Styles And Templates</title>
		<link>http://www.designersilverlight.com/2008/03/27/wpf-designers-guide-to-styles-and-templates/</link>
		<comments>http://www.designersilverlight.com/2008/03/27/wpf-designers-guide-to-styles-and-templates/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 20:45:04 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[styles]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[WPF Designer Guides]]></category>
		<category><![CDATA[XAML]]></category>
		<category><![CDATA[]]></category>
		<category><![CDATA[ContentPresenter]]></category>
		<category><![CDATA[WPF Designers Guide]]></category>

		<guid isPermaLink="false">http://www.designersilverlight.com/2008/03/27/wpf-designers-guide-to-styles-and-templates/</guid>
		<description><![CDATA[This is a post that has taken months to complete, but addresses something that I don’t think I&#8217;ve seen sufficiently covered for anyone who is new to WPF. Resultantly, we&#8217;re going to go through it slowly and I&#8217;m officially begging for additional questions at the end. Part of the problem with styles and templates in [...]]]></description>
			<content:encoded><![CDATA[<p>This is a post that has taken months to complete, but addresses something that I don’t think I&#8217;ve seen sufficiently covered for anyone who is new to WPF. Resultantly, we&#8217;re going to go through it slowly and I&#8217;m officially begging for additional questions at the end.</p>
<p>Part of the problem with styles and templates in WPF stems from the fact that Blend allows a wonderfully simply way of creating a copy of a template:</p>
<p><img src="http://www.designersilverlight.com/wp-content/uploads/2008/03/snt_editcontrolparts.png" alt="SNT_EditControlParts" /></p>
<p>It then gives you something that looks like this:</p>
<p><font color="#0000ff">&lt;</font><font color="#800000">Style</font> <font color="#ff0000">x:Key</font>=&#8221;<font color="#0000ff">My_Template</font>&#8221; <font color="#ff0000">TargetType</font>=&#8221;<font color="#b8860b">{x:Type Button}</font>&#8220;<font color="#0000ff">&gt;</font><br />
      <font color="#0000ff">&lt;</font><font color="#800000">Setter</font> <font color="#ff0000">Property</font>=&#8221;<font color="#0000ff">Template</font>&#8220;<font color="#0000ff">&gt;</font><br />
            <font color="#0000ff">&lt;</font><font color="#800000">Setter.Value</font><font color="#0000ff">&gt;<br />
</font>                  <font color="#0000ff">&lt;</font><font color="#800000">ControlTemplate</font> <font color="#ff0000">TargetType</font>=&#8221;<font color="#b8860b">{x:Type Button}</font>&#8220;<font color="#0000ff">&gt;</font><br />
                        <font color="#008000">&lt;!&#8211; blah blah blah &#8211;&gt;</font></p>
<p>So, from a usability point of view… I told it to create a Template and it created a style. I judged from this that styles and templates were roughly the same thing.</p>
<p>And I was confused.</p>
<p>So, first, I&#8217;ll try to explain styles and templates by explaining how they work and then I&#8217;ll draw an analogy that I hope is helpful.</p>
<p>Let&#8217;s say you have a button.</p>
<p><img src="http://www.designersilverlight.com/wp-content/uploads/2008/03/snt_basicbtn.png" alt="Hi_Button" /></p>
<p>You can change all sorts of properties of that button… visibility, background, width, height, margins, border thickness, alignment, font, whatever.</p>
<p>If you have a dozen buttons and you want them all to have the same properties, you can create a button style that specifies those properties and assigns them across the board. You can edit a style in Blend by selecting your control, clicking in the menu: &#8220;<strong>Objects -&gt; Edit Style -&gt; Edit a Copy…</strong>&#8220;.</p>
<p>Style editing in the objects tab will look like this.</p>
<p><img src="http://www.designersilverlight.com/wp-content/uploads/2008/03/snt_styleobjects.png" alt="Style_Objects" /></p>
<p>As you can see, there are no objects in the visual tree to play with… only properties to assign in the properties tab.</p>
<p><img src="http://www.designersilverlight.com/wp-content/uploads/2008/03/snt_styleproperties.png" alt="Button_Style_Properties" /></p>
<p>When you assign a property in Blend, your styles will save that assignment as setters and values. Let&#8217;s say we wanted all of our buttons to have green 18 point font  bold text. We could create a style that looked like this:</p>
<p><font color="#0000ff">&lt;</font><font color="#800000">Style</font> <font color="#ff0000">x:Key</font>=&#8221;<font color="#0000ff">GreenBorderButton</font>&#8221; <font color="#ff0000">TargetType</font>=&#8221;<font color="#b8860b">{x:Type Button}</font>&#8220;<font color="#0000ff">&gt;</font><br />
      <font color="#0000ff">&lt;</font><font color="#800000">Setter</font> <font color="#ff0000">Property</font>=&#8221;<font color="#0000ff">Foreground</font>&#8221; <font color="#ff0000">Value</font>=&#8221;<font color="#0000ff">#FF00FF00</font>&#8221; <font color="#0000ff">/&gt;</font><br />
      <font color="#0000ff">&lt;</font><font color="#800000">Setter</font> <font color="#ff0000">Property</font>=&#8221;<font color="#0000ff">FontSize</font>&#8221; <font color="#ff0000">Value</font>=&#8221;<font color="#0000ff">18</font>&#8220;<font color="#0000ff"> /&gt;</font><br />
      <font color="#0000ff">&lt;</font><font color="#800000">Setter</font> <font color="#ff0000">Property</font>=&#8221;<font color="#0000ff">FontWeight</font>&#8221; <font color="#ff0000">Value</font>=&#8221;<font color="#0000ff">Bold</font>&#8221; <font color="#0000ff">/&gt;</font><br />
<font color="#0000ff">&lt;/</font><font color="#800000">Style</font><font color="#0000ff">&gt;</font></p>
<p>The styles can only define properties that belong to the control type that they are styling (which is defined in the &#8220;<strong>TargetType</strong>&#8220;). Also, styles can only give information for properties the control already has and only in the way that the control is already set up. For example, because there is no property for changing the corner radius of a button, you can&#8217;t change the corner radius of a button using a button style.</p>
<p>However, what if we want to change something about the button that we can&#8217;t change with the given properties? For example, let&#8217;s say we wanted to see all the text show up twice.</p>
<p><img src="http://www.designersilverlight.com/wp-content/uploads/2008/03/snt_doublebtn.png" alt="Double_Button" /></p>
<p>In order to do this, we need to make what I&#8217;m going to call &#8220;structural changes&#8221; to our control. Structural changes are changes in the actual guts of the control, changes to the base elements that make up the control. For this we need a control template.</p>
<p>Boiled down to their essence, templates are little chunks of XAML that are inserted whenever you use your control. When you right click on something and go to  &#8220;<strong>Edit Control Parts (Template) -&gt; Edit a Copy…</strong>&#8220;, Blend takes the default XAML that makes up your control and places it in the resources so that you can change it at your whim.</p>
<p>You can get to the Control Template using the right-click method described at the top of this post. Your basic button template will look something like this:</p>
<p><img src="http://www.designersilverlight.com/wp-content/uploads/2008/03/snt_btntemplate.png" alt="Button_Template" /></p>
<p><font color="#0000ff">&lt;</font><font color="#800000">Style</font><font color="#ff0000"> x:Key</font>=&#8221;<font color="#0000ff">MyButtonStyle</font>&#8221; <font color="#ff0000">TargetType</font>=&#8221;<font color="#b8860b">{x:Type Button}</font>&#8220;<font color="#0000ff">&gt;</font><br />
      <font color="#0000ff">&lt;</font><font color="#800000">Setter</font> <font color="#ff0000">Property</font>=&#8221;<font color="#0000ff">Template</font>&#8221; <font color="#ff0000">Value</font>=&#8221;<font color="#b8860b">{DynamicResource MyButtonTemplate}</font>&#8221; <font color="#0000ff">/&gt;<br />
</font><font color="#0000ff">&lt;/</font><font color="#800000">Style</font><font color="#0000ff">&gt;</font></p>
<p><font color="#0000ff">&lt;</font><font color="#800000">ControlTemplate</font> <font color="#ff0000">x:Key</font>=&#8221;<font color="#0000ff">MyButtonTemplate</font>&#8221; <font color="#ff0000">TargetType</font>=&#8221;<font color="#b8860b">{x:Type Button}</font>&#8221; <font color="#0000ff">&gt;</font><br />
      <font color="#0000ff">&lt;</font><font color="#800000">Microsoft_Windows_Themes:ButtonChrome</font> <font color="#ff0000">x:Name</font>=&#8221;<font color="#0000ff">Chrome</font>&#8221; <font color="#0000ff">&gt;</font><br />
            <font color="#0000ff">&lt;</font><font color="#800000">ContentPresenter</font> <font color="#0000ff">/&gt;<br />
</font>      <font color="#0000ff">&lt;/</font><font color="#800000">Microsoft_Windows_Themes:ButtonChrome</font><font color="#0000ff">&gt;</font><br />
<font color="#0000ff">&lt;/</font><font color="#800000">ControlTemplate</font><font color="#0000ff">&gt;</font></p>
<p>We can go in and add an additional ContentPresenter in here, like so:</p>
<p><font color="#0000ff">&lt;</font><font color="#800000">ControlTemplate</font><font color="#ff0000"><font color="#800000"> </font>x:Key</font>=&#8221;<font color="#0000ff">MyButtonTemplate</font>&#8221; <font color="#ff0000">TargetType</font>=&#8221;<font color="#b8860b">{x:Type Button}</font>&#8221; <font color="#0000ff">&gt;</font><br />
      <font color="#0000ff">&lt;</font><font color="#800000">Microsoft_Windows_Themes:ButtonChrome</font> <font color="#ff0000">x:Name</font>=&#8221;<font color="#0000ff">Chrome</font>&#8221; <font color="#0000ff">&gt;<br />
</font>            <font color="#0000ff">&lt;</font><font color="#800000">Grid</font><font color="#0000ff">&gt;<br />
</font>                  <font color="#0000ff">&lt;</font><font color="#800000">Grid.RowDefinitions</font><font color="#0000ff">&gt;</font><br />
                        <font color="#0000ff">&lt;</font><font color="#800000">RowDefinition</font> <font color="#ff0000">Height</font>=&#8221;<font color="#0000ff">.5*</font>&#8221; <font color="#0000ff">/&gt;<br />
</font>                        <font color="#0000ff">&lt;</font><font color="#800000">RowDefinition</font> <font color="#ff0000">Height</font>=&#8221;<font color="#0000ff">.5*</font>&#8221; <font color="#0000ff">/&gt;</font><br />
                  <font color="#0000ff">&lt;</font><font color="#800000">Grid.RowDefinitions</font><font color="#0000ff">&gt;</font><br />
                  <font color="#0000ff">&lt;</font><font color="#800000">ContentPresenter</font> <font color="#ff0000">Grid.Row</font>=&#8221;<font color="#0000ff">0</font>&#8221; <font color="#0000ff">/&gt;</font><br />
                  <font color="#0000ff">&lt;</font><font color="#800000">ContentPresenter</font> <font color="#ff0000">Grid.Row</font>=&#8221;<font color="#0000ff">1</font>&#8221; <font color="#0000ff">/&gt;</font><br />
            <font color="#0000ff">&lt;/</font><font color="#800000">Grid</font><font color="#0000ff">&gt;</font><br />
      <font color="#0000ff">&lt;/</font><font color="#800000">Microsoft_Windows_Themes:ButtonChrome</font><font color="#0000ff">&gt;</font><br />
<font color="#0000ff">&lt;/</font><font color="#800000">ControlTemplate</font><font color="#0000ff">&gt;</font></p>
<p>And now our button shows all the content twice, one right on top of another.</p>
<p>The best way I&#8217;ve found to think about it is to think of your control as a car.</p>
<p>The dealer give the buyer a list of things that they can change about the car… interior color, leather or fabric seats, 4 or 6 cylinder engine… these are properties of the car… defined in the car &#8220;style&#8221;. (Basically, you can think of everything that you&#8217;re allowed to tweak <a href="http://www.toyota.com/byt/pub/setStartOptions.do?seriesCategory=3&amp;zipHolder=&amp;modelId=&amp;zipEditInputTextField=&amp;zipCode=84124">at this website </a>as the style of the car.)</p>
<p><font color="#0000ff">&lt;</font><font color="#800000">Style</font> <font color="#ff0000">x:Name</font>=&#8221;<font color="#0000ff">MySpecialCar</font>&#8221; <font color="#ff0000">TargetType</font>=&#8221;<font color="#b8860b">{x:Type Camry}</font>&#8221; <font color="#0000ff">&gt;</font><br />
      <font color="#0000ff">&lt;</font><font color="#800000">Setter</font> <font color="#ff0000">Property</font>=&#8221;<font color="#0000ff">ExteriorColor</font>&#8221; <font color="#ff0000">Value</font>=&#8221;<font color="#0000ff">Blue</font>&#8221; <font color="#0000ff">/&gt;</font><br />
      <font color="#0000ff">&lt;</font><font color="#800000">Setter </font><font color="#ff0000">Property</font>=&#8221;<font color="#0000ff">TransmissionType</font>&#8221; <font color="#ff0000">Value</font>=&#8221;<font color="#0000ff">5SpeedManual</font>&#8221; <font color="#0000ff">/&gt;<br />
</font><font color="#0000ff">&lt;/</font><font color="#800000">Style</font><font color="#0000ff">&gt;</font></p>
<p><img src="http://www.designersilverlight.com/wp-content/uploads/2008/03/snt_camerybasic.png" alt="Camery_Basic" /><br />
 <br />
But let&#8217;s say that the buyer doesn&#8217;t want a normal seat… she wants a big comfy chair in place of the regular drivers seat. This is something outside of the scope of the list of things she was allowed to choose from, so they have to draw up new blueprints for making this new car. They have to create a new car &#8220;template&#8221;.</p>
<p>If our normal Camry blueprint looks like this:</p>
<p><font color="#0000ff">&lt;</font><font color="#800000">ControlTemplate</font> <font color="#ff0000">x:Key</font>=&#8221;<font color="#0000ff">MySpecialCarBlueprint</font>&#8221; <font color="#ff0000">TargetType</font>=&#8221;<font color="#b8860b">{x:Type Camry}</font>&#8220;<font color="#0000ff">&gt;</font><br />
      <font color="#0000ff">&lt;</font><font color="#800000">CamryFrame</font> <font color="#ff0000">x:Name</font>=&#8221;<font color="#0000ff">CamryFrame</font>&#8221; <font color="#0000ff">&gt;</font><br />
            <font color="#0000ff">&lt;</font><font color="#800000">Seat</font> <font color="#ff0000">Type</font>=&#8221;<font color="#0000ff">Drivers</font> &#8221; <font color="#0000ff">/&gt;<br />
</font>            <font color="#0000ff">&lt;</font><font color="#800000">Seat</font> <font color="#ff0000">Type</font>=&#8221;<font color="#0000ff">FrontPassenger</font>&#8221; <font color="#0000ff">/&gt;</font><br />
            <font color="#0000ff">&lt;</font><font color="#800000">Seat</font> <font color="#ff0000">Type</font>=&#8221;<font color="#0000ff">BackBench</font>&#8221; <font color="#0000ff">/&gt;</font><br />
      <font color="#0000ff">&lt;/</font><font color="#800000">CamryFrame</font><font color="#0000ff">&gt;<br />
</font><font color="#0000ff">&lt;<font size="+0">/</font></font><font color="#800000">ControlTemplate</font><font color="#0000ff">&gt;</font></p>
<p>We can go in and replace :</p>
<p><font color="#0000ff">&lt;</font><font color="#800000">Seat</font> <font color="#ff0000">Type</font>=&#8221;<font color="#0000ff">Drivers</font> &#8221; <font color="#0000ff">/&gt;</font></p>
<p>With</p>
<p><font color="#0000ff">&lt;</font><font color="#800000">Seat</font> <font color="#ff0000">Type</font>=&#8221;<font color="#0000ff">ComfyChair</font>&#8221; <font color="#0000ff">/&gt;</font></p>
<p><img width="198" src="http://www.designersilverlight.com/wp-content/uploads/2008/03/comfychair.png" alt="ComfyChair" height="154" /></p>
<p>You may also notice that, with this model we could get rid of all the other seats except the drivers seat or we could add 12 new rows of seats. We can change anything about the car because we&#8217;re down into the original car blueprint.</p>
<p><strong>This is the basic difference between styles and templates. </strong></p>
<ul>
<li>A<em> style</em> is a list of properties that can be assigned in bulk to a control.</li>
<li>A<em> template</em> goes a big step further and actually defines the underlying structure of the control.</li>
</ul>
<p>You may be asking: &#8220;So how do these two work together? And what is this Data Template think I keep hearing about?&#8221;</p>
<p>Given that this post is getting dangerously long already, I&#8217;m going to address those issues in a couple more posts on styles and templates.</p>
<p>I&#8217;ll end on this note: if you are working in WPF and you&#8217;re having trouble with styles and templates, please read all of these posts (as I get to them) and ask questions in the comments section. I&#8217;m pretty good about getting to the comments questions and if the question is big enough, I&#8217;ll write a whole post on it. There are few things more vital to a WPF developer/designer than to have a firm grasp on styles and templates. It is in this understanding that the power of WPF really comes out.</p>
<ul>
<li>Who&#8217;s The Boss? Property Priority in Styles and Templates (coming soon)</li>
<li>Create Conditional Styles and Templates (With the Magic of Triggers) (coming soon)</li>
<li>So How Do Data Templates Fit Into All This? (coming soon)</li>
</ul>
<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.designersilverlight.com/2008/03/27/wpf-designers-guide-to-styles-and-templates/&amp;layout=standard&amp;show_faces=1&amp;width=450&amp;action=like&amp;colorscheme=light&amp;font=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px"></iframe><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=WPF+Designers+Guide+to+Styles+And+Templates+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D80" title="Post to Twitter"><img class="nothumb" src="http://www.designersilverlight.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=WPF+Designers+Guide+to+Styles+And+Templates+http%3A%2F%2Fdesignersilverlight.com%2F%3Fp%3D80" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.designersilverlight.com/2008/03/27/wpf-designers-guide-to-styles-and-templates/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

