<?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>Veracity Solutions Blog &#187; ContentPresenter</title>
	<atom:link href="http://blogs.veracitysolutions.com/tag/contentpresenter/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.veracitysolutions.com</link>
	<description>Software Consulting That Rocks</description>
	<lastBuildDate>Thu, 22 Apr 2010 17:21:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The WPF Designers Guide to Styling The ComboBox</title>
		<link>http://blogs.veracitysolutions.com/the-wpf-designers-guide-to-styling-the-combobox/</link>
		<comments>http://blogs.veracitysolutions.com/the-wpf-designers-guide-to-styling-the-combobox/#comments</comments>
		<pubDate>Fri, 08 Feb 2008 05:37:04 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[Combobox]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[WPF Designer Guides]]></category>
		<category><![CDATA[XAML]]></category>
		<category><![CDATA[ContentPresenter]]></category>
		<category><![CDATA[itemcontainerstyle]]></category>
		<category><![CDATA[ItemsPresenter]]></category>
		<category><![CDATA[style]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[WPF Designer Guide]]></category>

		<guid isPermaLink="false">http://www.designerwpf.com/2008/02/07/the-wpf-designers-guide-to-styling-the-combobox/</guid>
		<description><![CDATA[ The ComboBox is not the most complex of the WPF applications, but it can be a little tricky, so lets do a general overview post of it before we go into the specifics of how we&#8217;re going to make it work.
First of all, if you&#8217;re going to test your comboBox design, you should have it [...]]]></description>
			<content:encoded><![CDATA[<p> The ComboBox is not the most complex of the WPF applications, but it can be a little tricky, so lets do a general overview post of it before we go into the specifics of how we&#8217;re going to make it work.</p>
<p>First of all, if you&#8217;re going to test your comboBox design, you should have it hooked up to an ItemsSource. Don&#8217;t have one? I have a tutorial in which I walk through <a href="http://www.designerwpf.com/2007/12/13/how-do-i-connect-an-rss-feed-to-my-listviewlistboxwhatever/">attaching an RSS feed to your control</a>. It was originally written for the ListView, but it will work fine for a ComboBox.</p>
<p>To start out&#8230; this is your standard ComboBox:</p>
<p><img src="http://www.designerwpf.com/wp-content/uploads/2008/02/unalteredcombobox.png" alt="unalteredComboBox" /></p>
<p>When working on a comboBox, you have a couple of options for the Items inside the ComboBox. If the options never change and are not data-driven, you can just toss come ComboBoxItems into it. Otherwise, you can connect it to some kind of ItemsSource (see the link above).</p>
<p>All of my examples are done with a data-driven ComboBoxes, but you should get the desired results if you run through the tutorials with ComboBoxItems.</p>
<p>First, a little bit about the structure of the comboBox.</p>
<p><span id="more-228"></span></p>
<p>The comboBox consists of a couple basic elements. The main part that you would normally click on is a ToggleButton. The information we can see is a ContentPresenter. When you open the ComboBox, you get a popup that is holding an ItemsPresenter.</p>
<p>The ComboBox is a little different inasmuch as it has both a ContentPresenter and an ItemsPresenter, which means that it can take in two different DataTemplates for these different presenters. (If all this is confusing to you, subscribe to my RSS feed… I&#8217;m working on a guide to Styles and Templates which will explain all this in detail.)</p>
<p>Anyway, in the spirit of <a href="http://www.designerwpf.com/2007/12/06/the-wpf-designers-guide-to-styling-the-your-favorite-adjectival-swear-word-here-listview/">my guide to the ListView</a>, I&#8217;m just going to spend the rest of the time guiding you through the basics of how to style the ComboBox. As I get to it, I&#8217;ll write the accompanying articles going into each in detail.</p>
<p><strong>Question 1:</strong> &#8220;How do I style the items in the dropdown?&#8221;</p>
<p><img src="http://www.designerwpf.com/wp-content/uploads/2008/02/comboboxitems.png" alt="ComboItems" /></p>
<p><strong>Answer:</strong> Use the ItemContainerStyle and the accompanying template to define the look and feel of the items.</p>
<p><a href="http://www.designerwpf.com/2008/02/07/how-do-i-style-the-combobox-items/">How to edit the ComboBox ItemContainerStyle in Blend</a></p>
<p><strong>In the XAML:</strong></p>
<p>Put this in the resources:<br />
<font color="#0000ff">&lt;</font><font color="#800000">Style</font> <font color="#ff0000">x:Key</font>=&#8221;<font color="#0000ff">MyComboItemStyle</font>&#8221; <font color="#ff0000">TargetType</font>=&#8221;<font color="#cc9436">{x:Type ComboBoxItem}</font>&#8220;<font color="#0000ff">&gt;</font><br />
<font color="#0000ff">&lt;/</font><font color="#800000">Style</font><font color="#0000ff">&gt;</font></p>
<p>Put this in the composition:<br />
<font color="#0000ff">&lt;</font><font color="#800000">ComboBox</font><font color="#ff0000"> ItemContainerStyle</font>=&#8221;<font color="#cc9436">{DynamicResource MyComboItemStyle}</font>&#8221; <font color="#0000ff">/&gt;</font></p>
<p><strong>Question 2: </strong>&#8220;How do I change the look of the main ComboBox button (highlighted below)?&#8221;</p>
<p><img src="http://www.designerwpf.com/wp-content/uploads/2008/02/comboboxtoggle.png" alt="ComboToggle" /></p>
<p><strong>Answer:</strong> Use the standard Style and Template properties.</p>
<p>How to Style the main ComboBox in Blend (coming soon).</p>
<p><strong>In the XAML:</strong></p>
<p>Put this in the resources:<br />
<font color="#0000ff">&lt;</font><font color="#800000">Style</font> <font color="#ff0000">x:Key</font>=&#8221;<font color="#0000ff">MyComboStyle</font>&#8221; <font color="#ff0000">TargetType</font>=&#8221;<font color="#cc9436">{x:Type ComboBox}</font>&#8220;<font color="#0000ff">&gt;</font><br />
<font color="#0000ff">&lt;/</font><font color="#800000">Style</font><font color="#0000ff">&gt;</font></p>
<p>Put this in the composition:<br />
<font color="#0000ff">&lt;</font><font color="#800000">ComboBox</font><font color="#ff0000"> Style</font>=&#8221;<font color="#cc9436">{DynamicResource MyComboStyle}</font>&#8221; <font color="#0000ff">/&gt;</font></p>
<p><strong>Question 3:</strong> &#8220;How do I style the ComboBox dropdown (highlighted below)?&#8221;</p>
<p><img src="http://www.designerwpf.com/wp-content/uploads/2008/02/comboboxpopup.png" alt="ComboBoxPopup" /></p>
<p><strong>Answer:</strong> Go to the Popup control inside the ComboBox template.</p>
<p><a href="http://www.designerwpf.com/2008/03/24/styling-the-combobox-dropdown-popup/">How to style the ComboBox drop down in Blend.</a></p>
<p>In the XAML:</p>
<p>Put this in the resources:<br />
<font color="#0000ff">&lt;</font><font color="#800000">Style</font> <font color="#ff0000">x:Key</font>=&#8221;<font color="#0000ff">MyComboStyle</font>&#8221; <font color="#ff0000">TargetType</font>=&#8221;<font color="#cc9436">{x:Type ComboBox}</font>&#8220;<font color="#0000ff">&gt;<br />
      &lt;<font color="#800000">Setter</font><font color="#000000"> </font><font color="#ff0000">Property</font><font color="#000000">=&#8221;</font><font color="#0000ff">Template</font><font color="#000000">&#8220;</font></font><font color="#0000ff">&gt;<br />
            &lt;</font><font color="#800000">Setter.Value</font><font color="#0000ff">&gt;<br />
            &#8230;<br />
</font><font color="#0000ff">                  &lt;</font><font color="#800000">Popup</font> <font color="#ff0000">x:Name</font>=&#8221;<font color="#0000ff">PART_Popup</font>&#8221; <font color="#0000ff">&gt;</font><br />
<font color="#0000ff"><font color="#008000"><font color="#0000ff">                        </font>&lt;!&#8211; Edit here &#8211;&gt;<br />
</font>                  &lt;/</font><font color="#800000">Popup</font><font color="#0000ff">&gt;<br />
            &#8230;<br />
</font><font color="#0000ff">            &lt;/</font><font color="#800000">Setter.Value</font><font color="#0000ff">&gt;<br />
      &lt;/<font color="#800000">Setter</font>&gt;<br />
</font><font color="#0000ff">&lt;/<font color="#800000">Style</font><font color="#0000ff">&gt;</font></font></p>
<p>Put this in the composition:<br />
<font color="#0000ff">&lt;</font><font color="#800000">ComboBox</font><font color="#ff0000"> Style</font>=&#8221;<font color="#cc9436">{DynamicResource MyComboStyle}</font>&#8221; <font color="#0000ff">/&gt;</font></p>
<p>There are, of course, other questions related to the ComboBox, but this is just the basics. I&#8217;ll look at some of the more intense ComboBox styling tasks in the near future.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.veracitysolutions.com/the-wpf-designers-guide-to-styling-the-combobox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
