<?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>www.fooberry.com &#187; WPF</title>
	<atom:link href="http://fooberry.com/category/wpf/feed/" rel="self" type="application/rss+xml" />
	<link>http://fooberry.com</link>
	<description>Sweetness Without Context</description>
	<lastBuildDate>Fri, 30 Jul 2010 14:17:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>WPF Toolkit DataGrid, ColumnHeader Style and Blend</title>
		<link>http://fooberry.com/2008/11/17/wpf-toolkit-datagrid-columnheader-style-and-blend/</link>
		<comments>http://fooberry.com/2008/11/17/wpf-toolkit-datagrid-columnheader-style-and-blend/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 22:03:55 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[datagrid]]></category>
		<category><![CDATA[ReSharper]]></category>

		<guid isPermaLink="false">http://fooberry.com/?p=518</guid>
		<description><![CDATA[<br/>I&#8217;ve spent the better part of the day trying to figure out how to style the column headers of my WPF Toolkit datagrid through Microsoft Blend. Blend is a great tool and I couldn&#8217;t imagine trying to do a WPF application without it; however it is still immature and this could be why I found [...]]]></description>
			<content:encoded><![CDATA[<br/><p>I&#8217;ve spent the better part of the day trying to figure out how to style the column headers of my WPF Toolkit datagrid through Microsoft Blend. Blend is a great tool and I couldn&#8217;t imagine trying to do a WPF application without it; however it is still immature and this could be why I found it so difficult to figure out. It could just be that I&#8217;m new to  Blend, WPF, and XAML and still have a lot to learn.</p>
<p>I&#8217;ll spare you the agony I suffered this morning and jump right into the solution.</p>
<p>We have a pretty basic style for the datagrid at the moment. You&#8217;ll have to forgive the visual obfuscation.<br />
<img title="11" src="http://fooberry.com/wp-content/uploads/2008/11/11-300x69.png" alt="" width="300" height="69" /></p>
<p>Changing the the column header style looked pretty obvious in Blend. The menu walks me through the steps to create a resource for the header style.</p>
<p><img class="alignnone size-full wp-image-521" title="21" src="http://fooberry.com/wp-content/uploads/2008/11/21.png" alt="" width="747" height="653" /></p>
<p>Give the style resource a name. In this case I am going to show a pivoted set of data with a set of frozen columns on the left and columns that accept entering data on the right. I give it the name I want and choose its destination.<br />
<img class="alignnone size-full wp-image-522" title="31" src="http://fooberry.com/wp-content/uploads/2008/11/31.png" alt="" width="386" height="254" /></p>
<p>When the steps are complete, I have a style in the resources dictionary for my window, but something is missing.</p>
<p><img class="alignnone size-full wp-image-523" title="4" src="http://fooberry.com/wp-content/uploads/2008/11/4.png" alt="" width="345" height="464" /></p>
<div style="padding: 1em 0pt; text-align: left;">I&#8217;m not sure if I&#8217;m missing a step, but the target type of the resource is the generic IFrameInputElement type. It doesn&#8217;t provide any properties to set in the designer.<img class="alignnone size-full wp-image-524" title="5" src="http://fooberry.com/wp-content/uploads/2008/11/5.png" alt="" width="376" height="238" /></div>
<div style="padding: 1em 0pt; text-align: left;">If I look at the XAML that was created, it doesn&#8217;t give it a type.</div>
<pre language="xml" name="code">&lt;Style x:Key="EnterableColumnHeaderStyle"/&gt;</pre>
<p>The examples I&#8217;ve been seeing have a TargetType property to allow for the attached properties to work properly. I got ahead and add my TargetType property.</p>
<p><img class="alignnone size-full wp-image-525" title="6" src="http://fooberry.com/wp-content/uploads/2008/11/6.png" alt="" width="835" height="78" /></p>
<p>As you can see, I&#8217;m still learning WPF and XAML.  ReSharper steps in and offers to help out a bit. I am glad to let it. It adds the proper namespace to the resource:</p>
<pre language="xml" name="code">
&lt;Style x:Key="EnterableColumnHeaderStyle" TargetType="primitives:DataGridColumnHeader"&gt;
</pre>
<p>It also creates the namespace directive:</p>
<p><a href="http://fooberry.com/wp-content/uploads/2008/11/7.png"><img class="alignnone size-medium wp-image-526" title="7" src="http://fooberry.com/wp-content/uploads/2008/11/7-300x72.png" alt="" width="300" height="72" /></a></p>
<p>I don&#8217;t really like the namespace alias, so we&#8217;ll change it with the help of ReSharper.</p>
<div id="s8t." style="padding: 1em 0pt; text-align: left;"><img class="alignnone size-full wp-image-527" title="8" src="http://fooberry.com/wp-content/uploads/2008/11/8.png" alt="" width="500" height="173" /></div>
<p>Blend now knows our target type and gives us all the properties we could want to style.</p>
<div id="ydpf" style="padding: 1em 0pt; text-align: left;"><img class="alignnone size-full wp-image-528" title="9" src="http://fooberry.com/wp-content/uploads/2008/11/9.png" alt="" width="345" height="444" /></p>
<p>We can do whatever we want with the column header now.<img class="alignnone size-full wp-image-529" title="10" src="http://fooberry.com/wp-content/uploads/2008/11/10.png" alt="" width="500" height="240" /></p>
<p>And, just as we&#8217;d expect, we get our new style.</p>
<p><img class="alignnone size-full wp-image-530" title="111" src="http://fooberry.com/wp-content/uploads/2008/11/111.png" alt="" width="340" height="132" /></p>
<p>We can also apply a style to a particular column.</p>
<pre language="xml" name="code">
&lt;wpfToolkit:DataGridTextColumn x:Name="FirstColumn"   Header="Something"  HeaderStyle="{StaticResource FrozenColumnHeaderStyle }" &gt;
</pre>
<p><img class="alignnone size-full wp-image-519" title="12" src="http://fooberry.com/wp-content/uploads/2008/11/12.png" alt="" width="414" height="93" /></div>
]]></content:encoded>
			<wfw:commentRss>http://fooberry.com/2008/11/17/wpf-toolkit-datagrid-columnheader-style-and-blend/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>WPF Grid and Read Only Columns</title>
		<link>http://fooberry.com/2008/11/05/wpf-grid-and-read-only-columns/</link>
		<comments>http://fooberry.com/2008/11/05/wpf-grid-and-read-only-columns/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 19:47:01 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[data binding]]></category>
		<category><![CDATA[datagrid]]></category>

		<guid isPermaLink="false">http://fooberry.com/?p=478</guid>
		<description><![CDATA[<br/>In an attempt to provide a total summary column in a WPF data grid, I attempted to bind a read only column of a DataTable to a DataGridTextColumn of the WPFToolkit data grid. Initially, I tried to do the way I&#8217;ve been doing every other column. &#60;wpfToolkit:DataGridTextColumn Header="Total" DataFieldBinding="{Binding Total}" /> Unfortunately that gives us [...]]]></description>
			<content:encoded><![CDATA[<br/><p>In an attempt to provide a total summary column in a WPF data grid, I attempted to bind a read only column of a <code>DataTable</code> to a <code>DataGridTextColumn</code> of the <a href="http://www.codeplex.com/wpf">WPFToolkit</a> data grid. </p>
<p>Initially, I tried to do the way I&#8217;ve been doing every other column.</p>
<pre name="code" language="xml">
&lt;wpfToolkit:DataGridTextColumn
     Header="Total"
     DataFieldBinding="{Binding Total}"  />
</pre>
<p>Unfortunately that gives us the following error:</p>
<blockquote><p>
A TwoWay or OneWayToSource binding cannot work on the read-only property &#8216;Total&#8217; of type &#8216;System.Data.DataRowView&#8217;.</p></blockquote>
<p>OK, that makes sense, we should just adjust the mode of the binding and try again.</p>
<pre name="code" language="xml">
&lt;wpfToolkit:DataGridTextColumn
     Header="Total"
     DataFieldBinding="{Binding Total,Mode=OneWay}"  />
</pre>
<p>&#8230;.but we get the same error.  After a few quick Google searches, I found <a href="http://blogs.msdn.com/jaimer/archive/2008/08/13/dabbling-around-the-new-wpf-datagrid-part-1.aspx">someone else that already pointed out the issue and a possible workaround.</a> </p>
<blockquote><p><strong>ReadOnly columns</strong>  is missing from the CTP, but that is not a huge problem, you can easily accomplish ReadOnly behavior by using DataGridTemplateColumns and replacing the templates with read-only controls ( like TextBlocks).</p></blockquote>
<p> A quick change of the column to a <code>DataGridTemplateColumn</code> and it looks like we are off to the races. </p>
<pre name="code" language="xml">
&lt;wpfToolkit:DataGridTemplateColumn Header="Brand">
    &lt;wpfToolkit:DataGridTemplateColumn.CellTemplate>
        &lt;DataTemplate>
            &lt;TextBlock Text="{Binding Path=Brand,Mode=OneWay}" />
        &lt;/DataTemplate>
    &lt;/wpfToolkit:DataGridTemplateColumn.CellTemplate>
&lt;/wpfToolkit:DataGridTemplateColumn>
</pre>
<p><strong>NOTE:</strong> After another bit of searching on the web, the <a href="http://www.codeplex.com/wpf/Release/ProjectReleases.aspx?ReleaseId=15598">WPF Toolkit &#8211; October 2008</a> was released last week. This negates the need for the workaround for read only columns.</p>
<pre name="code" language="xml">
&lt;wpfToolkit:DataGridTextColumn
     Header="Total"
     Binding="{Binding Total}"
     IsReadOnly="True" />
</pre>
]]></content:encoded>
			<wfw:commentRss>http://fooberry.com/2008/11/05/wpf-grid-and-read-only-columns/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WPF Day 1</title>
		<link>http://fooberry.com/2008/10/11/wpf-day-1/</link>
		<comments>http://fooberry.com/2008/10/11/wpf-day-1/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 20:12:31 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://fooberry.com/2008/10/11/wpf-day-1/</guid>
		<description><![CDATA[<br/>Our new project at work has chosen WPF for our UI Framework. There is a nervous feeling around the office that WPF might not be the proper choice, due to the nature of WPF or the quality of the development staff and the staff to follow. After spending a few days in WPF and developing [...]]]></description>
			<content:encoded><![CDATA[<br/><p>Our new project at work has chosen WPF for our UI Framework. There is a nervous feeling around the office that WPF might not be the proper choice, due to the nature of WPF or the quality of the development staff and the staff to follow. After spending a few days in WPF and developing a really rough prototype, I have to admit I am pretty sure we will put both concerns to rest. WPF has so many features that make it suitable to Line of Business applications, whatever that term truly means. While I haven&#8217;t mastered WPF in the past few days, I have a fairly good understanding of those features and usage potential.</p>
<p>The hardest myth to overcome is that WPF is <em>only</em> for the shiny, glossy, media rich applications. While it is excellent at delivering those user experiences, it is filled with numerous techniques that would provide use to any desktop application (except maybe command line applications).</p>
<p>I&#8217;m not going to try and do a job of completely enumerating why I&#8217;m excited about <a href="http://www.thejoyofcode.com/10_reasons_you_should_consider_WPF_for_your_next_desktop_application.aspx">using WPF in a Line of Business application</a>, but a brief list might help to summarize them.</p>
<h2>Layout Managers</h2>
<p>My WinForms experience includes mostly .Net 1.1 and VB6 over the past 10 years or so, but I do have a sprinkle of experience doing UI in Java Swing. The layout managers Java had looked like they would be a <strong>huge</strong> advantage over the absolute position of .Net and VB6. WPF introduces similar functionality with content containers.</p>
<p>There are several devices for laying out controls on the design surface. Before, when using the .Net 1.1 devices such as <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock.aspx">Dock</a> it was very awkward to get the layout fluid. Controls required manual resizes and would often overlay other controls unexpectedly.</p>
<p>With new containers like <a title="StackPanel Class (System.Windows.Controls)" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel.aspx">StackPanel</a>, <a title="Grid Class (System.Windows.Controls)" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.grid.aspx">Grid</a>, <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.dockpanel.aspx">DockPanel</a>, etc. and the ability to nest them as needed, complex layouts become more manageable.</p>
<p>Even the controls themselves have the ability to be more flexible with their layout. Making three controls proportionally resize in WinForms required handling events, doing math to determine the new sizes based on the proportions and setting the sizes of each control. With WPF, you do the following:</p>
<pre>&lt;Grid&gt;
    &lt;Grid.RowDefinitions&gt;
        &lt;RowDefinition Height="1*" /&gt;
        &lt;RowDefinition Height="1*" /&gt;
        &lt;RowDefinition Height="1*" /&gt;
    &lt;/Grid.RowDefinitions&gt;
    &lt;TextBox Grid.Row="0" /&gt;
    &lt;TextBox Grid.Row="1" /&gt;
    &lt;TextBox Grid.Row="2" /&gt;
&lt;/Grid&gt;</pre>
<h2>Control Content Containers</h2>
<p>In WPF near everything is a container. You want a checkbox inside a button? No problem.</p>
<pre>&lt;Button&gt;
   &lt;CheckBox&gt;Cool&lt;Checkbox/&gt;
&lt;/Button&gt;</pre>
<p>Some controls, like <code>TextBox</code> doesn&#8217;t accept custom content. While this doesn&#8217;t appear useful at first, but the ability to override the content generated by list boxes provides am endless array of options. I imagine this will work like a repeater in ASP.Net.</p>
<h2>Data Binding</h2>
<p>By far the most impressive feature of WPF, at least to me, is the ability to bind, not only data elements, but also control properties and wire these bindings to other properties. There is a new rich model for binding almost anything to almost anything else. I know this seems a little vague at the moment.</p>
<p>The heart of the robust data binding is the <a title="DependencyProperty Class (System.Windows)" href="http://msdn.microsoft.com/en-us/library/system.windows.dependencyproperty.aspx">dependency property</a>. It allows for change notification as well as a few other nice features. Since the controls of WPF have their properties implemented by dependency properties, the binding is notified when they change and can bind the appropriate values.</p>
<p>Data binding could be used, for example to bind the font size of a grid cell to the value which it holds. We could a custom converter to convert the value of the cell to a font size or even to a color. Likewise, you could bind the text of a tooltip to an error message produced via a validator that is run when a text box value has its value changed.</p>
<h2>Baby Steps</h2>
<p>There are too many features to enumerate. I am about 250 pages into<a title="Amazon.com: Programming WPF: Chris Sells, Ian Griffiths: Books" href="http://amazon.com/dp/0596510373"> Programming WPF</a>. <a href="http://www.amazon.com/dp/0596510373"><img class="alignleft size-full wp-image-418" title="Programming WPF" src="http://fooberry.com/wp-content/uploads/2008/10/9780596510374_cat.gif" alt="" width="180" height="236" /></a>I usually hate buying language books and prefer something with a little more longevity, but so far it has been a really fast read. I can&#8217;t say it is going to be the last WPF book anyone will every need, but coming from zero WPF knowledge, it has shed some light on the features of WPF that I see valuable. There are many more things mentioned in the book that I forgot to mention, haven read yet, poorly or entirely incorrectly phrased. :S This is by no means an expert synopsis of WPF.</p>
<p>While I&#8217;ve gotten my hands slightly dirty in WPF over the past week, I haven&#8217;t even begun to leverage its full power. I plan on keeping everyone abreast of my progress, short comings, troubles and successes&#8230;hopefully more of the later.</p>
<p>I am considering keeping a sample project running to show where I&#8217;m at in my WPF journey, but haven&#8217;t decided if it will be of value or interest to anyone. It would most likely be a simplified obfuscated version of my current project and a testbed for running spikes.</p>
]]></content:encoded>
			<wfw:commentRss>http://fooberry.com/2008/10/11/wpf-day-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
