<?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; Column</title>
	<atom:link href="http://blogs.veracitysolutions.com/tag/column/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>How Do I Center Something In My ListView Column?</title>
		<link>http://blogs.veracitysolutions.com/how-do-i-center-something-in-my-listview-column/</link>
		<comments>http://blogs.veracitysolutions.com/how-do-i-center-something-in-my-listview-column/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 20:09:26 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[Blend]]></category>
		<category><![CDATA[ListView]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML]]></category>
		<category><![CDATA[celltemplate]]></category>
		<category><![CDATA[Column]]></category>
		<category><![CDATA[DataTemplate]]></category>
		<category><![CDATA[itemcontainerstyle]]></category>

		<guid isPermaLink="false">http://www.designerwpf.com/2007/12/17/how-do-i-center-something-in-my-listview-column/</guid>
		<description><![CDATA[So the items in your ListView column look like this:

And you want them to look like this:

If you&#8217;re trying to center something within a ListView column, it&#8217;s actually pretty simple.

First, go to your ListView and, if you haven&#8217;t already, create an ItemContainerStyle by going to the Object -&#62; Edit Other Styles&#8230; -&#62; Edit ItemContainerStyle -&#62; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.designerwpf.com/wp-content/uploads/2007/12/centeredexample2.png" title="Centered Example 2"></a><a href="http://www.designerwpf.com/wp-content/uploads/2007/12/centeredexample1.png" title="Centered Example 1"></a><a href="http://www.designerwpf.com/wp-content/uploads/2007/12/itemcontainerstyle.png" title="ItemContainerStyle Menu"></a>So the items in your ListView column look like this:</p>
<p><img src="http://www.designerwpf.com/wp-content/uploads/2007/12/centeredexample1.png" alt="Centered Example 1" /></p>
<p>And you want them to look like this:</p>
<p><img src="http://www.designerwpf.com/wp-content/uploads/2007/12/centeredexample2.png" alt="Centered Example 2" /></p>
<p>If you&#8217;re trying to center something within a ListView column, it&#8217;s actually pretty simple.</p>
<p><span id="more-113"></span></p>
<p>First, go to your ListView and, if you haven&#8217;t already, create an ItemContainerStyle by going to the <strong>Object -&gt; Edit Other Styles&#8230; -&gt; Edit ItemContainerStyle -&gt; Create Empty&#8230;</strong></p>
<p><img src="http://www.designerwpf.com/wp-content/uploads/2007/12/itemcontainerstyle.png" alt="ItemContainerStyle Menu" /></p>
<p>Within your ItemContainerStyle, set the <font color="#ff0000">HorizontalContentAlignment</font> from &#8220;<font color="#0000ff">Left</font>&#8221; to &#8220;<font color="#0000ff">Stretch</font>&#8220;.</p>
<p>Your ItemContainerStyle XAML should now look like this (important stuff in bold):</p>
<p><font color="#0000ff">&lt;<font color="#800000">Style</font> <font color="#ff0000">x:Key</font><font color="#000000">=&#8221;</font>MyItemContainerStyle<font color="#000000">&#8220;</font> <font color="#ff0000">TargetType</font><font color="#000000">=&#8221;</font><font color="#b8860b">{x:Type ListViewItem}</font><font color="#000000">&#8220;</font>&gt;<br />
      <strong>&lt;<font color="#800000">Setter</font> <font color="#ff0000">Property</font><font color="#000000">=&#8221;</font>HorizontalContentAlignment<font color="#000000">&#8220;</font> <font color="#ff0000">Value</font><font color="#000000">=&#8221;</font>Stretch<font color="#000000">&#8220;</font>/&gt;</strong><br />
&lt;/<font color="#800000">Style</font>&gt;</font></p>
<p>A point of note: if you want everything to be centered, you can set it to &#8220;<font color="#0000ff">Center</font>&#8220;. However, if you prefer more control over the layout of your columns (as I do), set it to stretch.</p>
<p>Now, go to the DataTemplate for the column you want to center. (If you don&#8217;t know how to get to the DataTemplate or how to create one, you can <a href="http://www.designerwpf.com/2007/12/13/styling-a-listview-column-using-blend/">find that information here</a>. Just look for &#8220;DataTemplate&#8221;.)</p>
<p>Within the DataTemplate, align your bound item so that the <font color="#ff0000">HorizontalAlignment</font> is set to &#8220;<font color="#0000ff">Center</font>&#8220;.</p>
<p>Your DataTemplate should now look something like this (important stuff in bold):</p>
<p><font color="#0000ff">&lt;</font><font color="#800000">DataTemplate</font> <font color="#ff0000">x:Key</font>=&#8221;<font color="#0000ff">AuthorTemplate</font>&#8220;<font color="#0000ff">&gt;</font><br />
      <font color="#0000ff">&lt;</font><font color="#800000">TextBlock</font> <font color="#ff0000">Text</font>=&#8221;<font color="#b8860b">{Binding Mode=OneWay, XPath=author}</font>&#8221; <font color="#ff0000">FontSize</font>=&#8221;<font color="#0000ff">12</font>&#8221;  <strong><font color="#ff0000">HorizontalAlignment</font>=&#8221;<font color="#0000ff">Center</font>&#8220;</strong> <font color="#0000ff">/&gt;</font><br />
<font color="#0000ff">&lt;/</font><font color="#800000">DataTemplate</font><font color="#0000ff">&gt;</font></p>
<p>Finally, your ListView should already be set up, but just to double check, make sure that your ListView XAML looks something like this:</p>
<p><font color="#0000ff">&lt;</font><font color="#800000">ListView</font> <strong><font color="#ff0000">ItemContainerStyle</font>=&#8221;<font color="#b8860b">{DynamicResource MyItemContainerStyle}</font>&#8220;</strong> <font color="#0000ff">&gt;</font><br />
      <font color="#0000ff">&lt;</font><font color="#800000">ListView.View</font><font color="#0000ff">&gt;</font><br />
            <font color="#0000ff">&lt;</font><font color="#800000">GridView</font><font color="#0000ff">&gt;<br />
</font>                  <font color="#0000ff">&lt;</font><font color="#800000">GridViewColumn</font> <strong><font color="#ff0000">CellTemplate</font>=&#8221;<font color="#b8860b">{DynamicResource AuthorTemplate}</font>&#8220;</strong> <font color="#ff0000">Header</font>=&#8221;<font color="#0000ff">Author</font>&#8220;<font color="#0000ff">/&gt;</font><br />
            <font color="#0000ff">&lt;/</font><font color="#800000">GridView</font><font color="#0000ff">&gt;</font><br />
      <font color="#0000ff">&lt;/</font><font color="#800000">ListView.View</font><font color="#0000ff">&gt;<br />
</font><font color="#0000ff">&lt;/</font><font color="#800000">ListView</font><font color="#0000ff">&gt;</font></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.veracitysolutions.com/how-do-i-center-something-in-my-listview-column/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Styling A ListView Column Using Blend</title>
		<link>http://blogs.veracitysolutions.com/styling-a-listview-column-using-blend/</link>
		<comments>http://blogs.veracitysolutions.com/styling-a-listview-column-using-blend/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 14:18:09 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[Blend]]></category>
		<category><![CDATA[How To...]]></category>
		<category><![CDATA[ListView]]></category>
		<category><![CDATA[XAML]]></category>
		<category><![CDATA[Column]]></category>
		<category><![CDATA[ColumnTemplate]]></category>
		<category><![CDATA[DataTemplate]]></category>
		<category><![CDATA[GridViewColumn]]></category>
		<category><![CDATA[styling]]></category>

		<guid isPermaLink="false">http://www.designerwpf.com/2007/12/13/styling-a-listview-column-using-blend/</guid>
		<description><![CDATA[So you&#8217;ve got a listview and you want the columns (not the rows) to look a certain way. (If you are in any way confused, head over here.)
In this post, we&#8217;re going to build a template for a column and style that template so the data in that column is all styled the same way, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.designerwpf.com/wp-content/uploads/2007/12/edititemtemplate.png" title="EditCopyItemTemplate"></a><a href="http://www.designerwpf.com/wp-content/uploads/2007/12/edititemtemplate2.png" title="Edit Item Template 2"></a><a href="http://www.designerwpf.com/wp-content/uploads/2007/12/celltemplate-example.png" title="CellTemplate Example"></a><a href="http://www.designerwpf.com/wp-content/uploads/2007/12/celltemplatemenu.png" title="CellTemplate Menu"></a>So you&#8217;ve got a listview and you want the columns (not the rows) to look a certain way. (If you are in any way confused, <a href="http://www.designerwpf.com/2007/12/06/the-wpf-designers-guide-to-styling-the-your-favorite-adjectival-swear-word-here-listview/">head over here</a>.)</p>
<p>In this post, we&#8217;re going to build a template for a column and style that template so the data in that column is all styled the same way, but different from the data in the rest of the list view. Kind of like this:</p>
<p><img src="http://www.designerwpf.com/wp-content/uploads/2007/12/celltemplate-example.png" alt="CellTemplate Example" /></p>
<p><strong>If you&#8217;re following from the RSS Feed post</strong>: go to the listview in the main composition and right click on your listivew and go to <em>&#8220;Edit Other Templates -&gt; Edit Generated Item (ItemTemplate) -&gt; Edit a Copy&#8230;&#8221;</em></p>
<p><strong>Not following from the RSS Feed post:</strong> go to the listview in your composition, right click on your listview and co to <em>&#8220;Edit Other Templates -&gt; Edit Generated Item (ItemTempalte) -&gt; Create Empty&#8230;&#8221;</em></p>
<p><img src="http://www.designerwpf.com/wp-content/uploads/2007/12/edititemtemplate2.png" alt="Edit Item Template 2" /></p>
<p> Name it whatever you like (I named mine &#8220;TitleTemplate&#8221;) and hit OK.</p>
<p><span id="more-106"></span><strong>RSS:</strong> If you had a template Blend will create a copy of your original source template with all the bindings in place. Get rid of all the bindings you don&#8217;t want. I think the easiest way is to simply go into the XAML and do this. Right click on any item and click the &#8220;View XAML&#8221; and delete any binding that doesn&#8217;t have &#8220;title&#8221; in it. When we&#8217;re done, your XAML should look like this:</p>
<p><font color="#0000ff">&lt;<font color="#800000">DataTemplate</font> <font color="#ff0000">x:Key</font><font color="#000000">=&#8221;</font>TitleTemplate<font color="#000000">&#8220;</font>&gt;<br />
      &lt;<font color="#800000">StackPanel</font>&gt;<br />
            &lt;<font color="#800000">TextBlock</font> <font color="#ff0000">Text</font><font color="#000000">=&#8221;</font><font color="#b8860b">{Binding Mode=OneWay, XPath=title}</font><font color="#000000">&#8220;</font> /&gt;<br />
      &lt;/<font color="#800000">StackPanel</font>&gt;<br />
&lt;/<font color="#800000">DataTemplate</font>&gt;</font></p>
<p><strong>Not RSS:</strong> Blend will create the basic DataTemplate markup for you and toss you into a DataTemplate editing mode.</p>
<p>From here, you can draw a Grid directly into the composition and a TextBlock directly into the Grid. Reset the Width and Height of the Grid and TextBlock to Auto and reset the Margins to &#8220;0,0,0,0&#8243;. Assign the TextBlock the proper Bindings in order to get it to show the proper data. Your XAML should look something like this.</p>
<p><font color="#0000ff">&lt;</font><font color="#800000">DataTemplate</font><font color="#0000ff"> </font><font color="#ff0000">x:Key</font><font color="#000000">=&#8221;</font><font color="#0000ff">TitleTemplate</font><font color="#000000">&#8220;</font><font color="#0000ff">&gt;<br />
      &lt;</font><font color="#800000">Grid</font><font color="#0000ff">&gt;<br />
            &lt;</font><font color="#800000">TextBlock</font><font color="#0000ff"> </font><font color="#ff0000">Text</font><font color="#000000">=&#8221;</font><font color="#b8860b">{Binding MySpecialBindings}</font><font color="#000000">&#8220;</font><font color="#0000ff"> /&gt;<br />
      &lt;/</font><font color="#800000">Grid</font><font color="#0000ff">&gt;<br />
&lt;/</font><font color="#800000">DataTemplate</font><font color="#0000ff">&gt;</font></p>
<p><datatemplate x:Key="TitleTemplate"></datatemplate><stackpanel></stackpanel><textblock Text="{Binding Mode=OneWay, XPath=title}"></textblock><strong>Note:</strong> If you need to get back to a design view of your DataTemplate, just go the resources tab on the right, expand wherever you saved your template and click on the right hand icon of template you want to edit. For DataTemplates, this icon is unhelpfully blank.</p>
<p><img src="http://www.designerwpf.com/wp-content/uploads/2007/12/selectdatatemplatefromresources.png" alt="Select DataTemplate from Resources" /></p>
<p>From here we can style the TextBlock directly in the DataTemplate using the Properties panel. Bold it, color it, skew it, turn it upsidedown, give it TextTrimming or TextWrapping or whatever we want. When finished, head back to the main composition view.</p>
<p>Click on the listview and, in the Properties section, expand &#8220;<em>Miscellaneous</em>&#8221; and then expand &#8220;<em>View (GridView)</em>&#8221; and click on the &#8220;<em>Columns (Collection)</em>&#8221; button.</p>
<p> <img src="http://www.designerwpf.com/wp-content/uploads/2007/12/view-gridview-columns-menu.png" alt="View GridView" /></p>
<p>Up pops the &#8220;GridViewColumn Collection Editor: Columns&#8221; window (which should be labeled something less obfuscating like &#8220;ListView Column Editor&#8221;).</p>
<p>Here we can create columns to aptly aid our evil schemes. If you&#8217;re following along from my RSS tutorial, we can create three new columns using the &#8220;Add Another Item&#8221; button (which should be labeled &#8220;Add Another Column&#8221;) and give them the following headers using the Header input in the Properties section:</p>
<p>&#8220;Title&#8221;<br />
&#8220;Author&#8221;<br />
&#8220;Description&#8221;<br />
&#8220;Publication Date&#8221;</p>
<p>If we want all our data to look the same with basic text elements and no fancy stuff, we can use DisplayMemberBinding and check out my post on that (coming soon).</p>
<p>However, if we want the special styling applied, we can choose the particular GridViewColumn to be specially styled and apply the template we&#8217;ve created.</p>
<p>(I feel like I&#8217;m writing a choose-your-own-adventure here. &#8220;If you want Johnny to answer the doorbell, turn to page 57. If you want Johnny to escape out the window, turn to page 23.&#8221;)</p>
<p>Anyway.</p>
<p>Click on the GridViewColumn with the &#8220;Title&#8221; header and click the little box to the right of &#8220;CellTemplate&#8221; In the resulting menu click on &#8220;Local Resource&#8221; and select the DataTemplate that we&#8217;ve just created. Click &#8220;OK&#8221;.</p>
<p><img src="http://www.designerwpf.com/wp-content/uploads/2007/12/celltemplatemenu.png" alt="CellTemplate Menu" /></p>
<p>And viola! Our listview shows up all sorts of custom designed happiness.</p>
<p><a href="http://www.designerwpf.com/2007/12/11/listview-faq/">ListView Frequently Asked Questions</a> pertaining to ColumnHeader issues:</p>
<blockquote><p><em>How do I make it so that, instead of cutting off the text in my column when I shorten it, my text displays ellipsis? (Example: &#8220;blahblahb…&#8221;)</em></p></blockquote>
<p>which is closely related to:</p>
<blockquote><p><em>How do I make it so that my text wraps when I shorten my columns?</em></p></blockquote>
<p>So <a href="http://www.designerwpf.com/2007/12/13/ellipsis-and-textwrapping-in-a-listview-column/">I deal with them in the same post here</a>.</p>
<blockquote><p><em>My binding points to an image source. How do I make it so that the image it points to shows up in the column instead of the stupid image source? (coming soon)</em><br />
<em><a href="http://www.designerwpf.com/2007/12/17/how-do-i-center-something-in-my-listview-column/">How do I center something in my ListView column?</a></em> </p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blogs.veracitysolutions.com/styling-a-listview-column-using-blend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ListView FAQ</title>
		<link>http://blogs.veracitysolutions.com/listview-faq/</link>
		<comments>http://blogs.veracitysolutions.com/listview-faq/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 22:19:04 +0000</pubDate>
		<dc:creator>Matthias Shapiro</dc:creator>
				<category><![CDATA[ListView]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Column]]></category>
		<category><![CDATA[FAQ WPF]]></category>
		<category><![CDATA[grid lines]]></category>

		<guid isPermaLink="false">http://www.designerwpf.com/2007/12/11/listview-faq/</guid>
		<description><![CDATA[Please feel free to post additional questions in the comments section. I&#8217;ll get to them as I can and then link the help here.

How do I get grid lines to show up in the ListView? 
How do I style a specific column in a ListView?
How do I make it so that, instead of cutting off the [...]]]></description>
			<content:encoded><![CDATA[<p>Please feel free to post additional questions in the comments section. I&#8217;ll get to them as I can and then link the help here.</p>
<ul>
<li><a href="http://www.designerwpf.com/2007/12/11/how-do-i-set-up-grid-lines-for-my-listview/">How do I get grid lines to show up in the ListView?</a><em> </em></li>
<li><a href="http://www.designerwpf.com/2007/12/13/styling-a-listview-column-using-blend/">How do I style a specific column in a ListView?</a></li>
<li><a href="http://www.designerwpf.com/2007/12/13/ellipsis-and-textwrapping-in-a-listview-column/">How do I make it so that, instead of cutting off the text in my column when I shorten it, my text displays ellipsis?</a></li>
<li><a href="http://www.designerwpf.com/2007/12/13/ellipsis-and-textwrapping-in-a-listview-column/">How do I make it so that my text wraps when I shorten my columns?</a></li>
<li><a href="http://www.designerwpf.com/2007/12/17/how-do-i-center-something-in-my-listview-column/">How do I center something in my ListView column?</a></li>
<li><a href="http://www.designerwpf.com/2008/02/02/how-do-i-wrap-text-in-a-listview-header/">How do I wrap text in a ListView header?</a></li>
<li><a href="http://www.designerwpf.com/2008/01/25/embedded-listview-columns-columns-within-columns/">How do I embed ListView Columns in another Column?</a> (Columns with Categories) </li>
<li><a href="http://www.designerwpf.com/2008/01/23/how-do-i-style-the-listview-column-gripper-also-known-as-a-splitter-or-a-seperator/">How do I style the ListView column gripper?</a> (the gripper is also called a &#8220;splitter&#8221; and a &#8220;seperator&#8221;)</li>
</ul>
<p>That&#8217;s all I got for now. Ask me some questions if you want more stuff.</p>
<p>If you&#8217;re looking for something more generic, check out my <a href="http://www.designerwpf.com/2007/12/06/the-wpf-designers-guide-to-styling-the-your-favorite-adjectival-swear-word-here-listview/">WPF Designers Guide to the ListView</a>, which covers the broader topics in the ListView.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.veracitysolutions.com/listview-faq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
