<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>{Wpf.Answers}</title>
	<atom:link href="http://wpfanswers.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpfanswers.wordpress.com</link>
	<description>Learning WPF 1 day at a time</description>
	<lastBuildDate>Tue, 26 Aug 2008 21:27:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='wpfanswers.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>{Wpf.Answers}</title>
		<link>http://wpfanswers.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://wpfanswers.wordpress.com/osd.xml" title="{Wpf.Answers}" />
	<atom:link rel='hub' href='http://wpfanswers.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Hello WPF</title>
		<link>http://wpfanswers.wordpress.com/2008/08/22/hello-wpf/</link>
		<comments>http://wpfanswers.wordpress.com/2008/08/22/hello-wpf/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 17:02:55 +0000</pubDate>
		<dc:creator>wpfanswers</dc:creator>
				<category><![CDATA[Note to Self]]></category>

		<guid isPermaLink="false">http://wpfanswers.wordpress.com/2008/08/22/hello-wpf/</guid>
		<description><![CDATA[I started this blog to leave some breadcrumbs along my path from Windows Forms programming to the world of WPF.&#160; So here we go!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wpfanswers.wordpress.com&amp;blog=4585854&amp;post=4&amp;subd=wpfanswers&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I started this blog to leave some breadcrumbs along my path from Windows Forms programming to the world of WPF.&nbsp; So here we go!</p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/wpfanswers.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/wpfanswers.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wpfanswers.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wpfanswers.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wpfanswers.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wpfanswers.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/wpfanswers.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/wpfanswers.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/wpfanswers.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/wpfanswers.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wpfanswers.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wpfanswers.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wpfanswers.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wpfanswers.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wpfanswers.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wpfanswers.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wpfanswers.wordpress.com&amp;blog=4585854&amp;post=4&amp;subd=wpfanswers&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://wpfanswers.wordpress.com/2008/08/22/hello-wpf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d6455fe93c0a486d885756a15690e5c9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">wpfanswers</media:title>
		</media:content>
	</item>
		<item>
		<title>Basic WPF Layout Sample &#8211; Day 1</title>
		<link>http://wpfanswers.wordpress.com/2008/08/22/basic-wpf-layout-sample-day-1/</link>
		<comments>http://wpfanswers.wordpress.com/2008/08/22/basic-wpf-layout-sample-day-1/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 21:13:36 +0000</pubDate>
		<dc:creator>wpfanswers</dc:creator>
				<category><![CDATA[WPF Layout]]></category>
		<category><![CDATA[WPF Layout GridControl Margin]]></category>

		<guid isPermaLink="false">http://wpfanswers.wordpress.com/2008/08/22/basic-wpf-layout-sample-day-1/</guid>
		<description><![CDATA[In learning WPF I wanted to see how I could break down an app&#8217;s UI into discrete elements and implement the interface using the WPF Layout Controls. So let me start with the basic requirements of what I want to try and implement, the easiest way to do that is sketch it out.&#160;&#160; Thought process&#8230;In [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wpfanswers.wordpress.com&amp;blog=4585854&amp;post=15&amp;subd=wpfanswers&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dailyworkbreak.com/blogresources/BasicWPFLayoutSample_B8D3/UISkeleton1.png"><img style="border-width:0;" height="236" alt="UI Skeleton1" src="http://www.dailyworkbreak.com/blogresources/BasicWPFLayoutSample_B8D3/UISkeleton1_thumb.png" width="373" align="right" border="0"></a>
<p>In learning WPF I wanted to see how I could break down an app&#8217;s UI into discrete elements and implement the interface using the WPF Layout Controls. So let me start with the basic requirements of what I want to try and implement, the easiest way to do that is sketch it out.&nbsp;&nbsp; </p>
<p>Thought process&#8230;In looking at the wireframe of the desired UI a couple of concepts come to mind. I&#8217;m not sure which is best so I&#8217;ll try both.&nbsp; </p>
<p><em><u>Concept 1 &#8211; Using the Grid control with 3 Rows Columns defined</u></em></p>
<ul>
<li>Row 1 &#8211; will hold menu (span both cols)
<li>Row 2
<ul>
<li>Col 1 &#8211; holds a stack panel
<ul>
<li>Stack panel holds 3 expandable panels</li>
</ul>
<li>Col 2 holds a main content area</li>
</ul>
<li>Row 3 &#8211; hold status bar (span both cols)</li>
</ul>
<p><em><u>Concept 2 &#8211; Using DockPanel with Grid</u></em></p>
<ul>
<li>DockPanel with 3 items
<ul>
<li>Menu docked to top
<li>status bar docked to bottom
<li>Grid (1 row, 2 columns) to fill rest of area
<ul>
<li>Column 1 &#8211; holds stack panel
<ul>
<li>stack panel contains 3 expandable panels</li>
</ul>
<li>Column 2 &#8211; holds main content area</li>
</ul>
</li>
</ul>
</li>
</ul>
<p><strong><u><font size="3">Concept 1- The Grid Control</font></u></strong></p>
<p> So lets try laying this out in XAML.&nbsp; The first thing is to setup the grid definition by defining the rows and cols and their sizes. </p>
<blockquote><pre class="code"><span style="color:blue;">&lt;</span><span style="color:#a31515;">Window </span><span style="color:red;">x</span><span style="color:blue;">:</span><span style="color:red;">Class</span><span style="color:blue;">="BasicWPFLayoutSample.Window1"
    </span><span style="color:red;">xmlns</span><span style="color:blue;">="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    </span><span style="color:red;">xmlns</span><span style="color:blue;">:</span><span style="color:red;">x</span><span style="color:blue;">="http://schemas.microsoft.com/winfx/2006/xaml"
    </span><span style="color:red;">Title</span><span style="color:blue;">="Window1" </span><span style="color:red;">Height</span><span style="color:blue;">="768" </span><span style="color:red;">Width</span><span style="color:blue;">="1024"&gt;
    &lt;</span><span style="color:#a31515;">Grid </span><span style="color:red;">ShowGridLines</span><span style="color:blue;">="True"&gt;
        &lt;</span><span style="color:#a31515;">Grid.RowDefinitions</span><span style="color:blue;">&gt;
            &lt;</span><span style="color:#a31515;">RowDefinition </span><span style="color:red;">Height</span><span style="color:blue;">="30" /&gt;
            &lt;</span><span style="color:#a31515;">RowDefinition </span><span style="color:red;">Height</span><span style="color:blue;">="*" /&gt;
            &lt;</span><span style="color:#a31515;">RowDefinition </span><span style="color:red;">Height</span><span style="color:blue;">="30" /&gt;
        &lt;/</span><span style="color:#a31515;">Grid.RowDefinitions</span><span style="color:blue;">&gt;
        &lt;</span><span style="color:#a31515;">Grid.ColumnDefinitions</span><span style="color:blue;">&gt;
            &lt;</span><span style="color:#a31515;">ColumnDefinition </span><span style="color:red;">Width</span><span style="color:blue;">="200*" /&gt;
            &lt;</span><span style="color:#a31515;">ColumnDefinition </span><span style="color:red;">Width</span><span style="color:blue;">="804*" /&gt;
        &lt;/</span><span style="color:#a31515;">Grid.ColumnDefinitions</span><span style="color:blue;">&gt;
    &lt;/</span><span style="color:#a31515;">Grid</span><span style="color:blue;">&gt;
&lt;/</span><span style="color:#a31515;">Window</span><span style="color:blue;">&gt;</span></pre>
</blockquote>
<p>This sets up 3 rows for the menu, content and status bar areas and 2 columns to host the main controls on the 2nd row. Notice the <span style="color:red;">ShowGridLines</span> attribute is set to True.&nbsp; This makes the grid regions visible when the app is run and is useful in laying out the structure. </p>
<p>You will notice there are 3 types of notation for setting height:</p>
<ul>
<li><span style="color:red;">Height</span><span style="color:blue;">=&#8221;30&#8243;</span>: </li>
<ul>
<li>Absolute Sizing &#8211; does not grow or shrink as size changes</li>
</ul>
<li><span style="color:red;">Height</span><span style="color:blue;">=&#8221;*&#8221; </span>:</li>
<ul>
<li>Proportional Sizing (star sizing) &#8211; Use all the remaining space and it grows and shrinks as the grid is resized</li>
</ul>
<li><span style="color:blue;">&lt;</span><span style="color:#a31515;">ColumnDefinition </span><span style="color:red;">Width</span><span style="color:blue;">=&#8221;200*&#8221; /&gt; &lt;</span><span style="color:#a31515;">ColumnDefinition </span><span style="color:red;">Width</span><span style="color:blue;">=&#8221;804*&#8221; /&gt; :</span></li>
<ul>
<li>Multiple Column Proportional Sizing (star sizing) &#8211; Resize based on the ratio the 2nd col will be roughly 4 times the size of the first</li>
<li>This is equivalent to <span style="color:blue;">&lt;</span><span style="color:#a31515;">ColumnDefinition </span><span style="color:red;">Width</span><span style="color:blue;">=&#8221;1*&#8221; /&gt; &lt;</span><span style="color:#a31515;">ColumnDefinition </span><span style="color:red;">Width</span><span style="color:blue;">=&#8221;4*&#8221; /&gt; </span></li>
</ul>
</ul>
<p>For this layout we set the 1st and 3rd row to be of an absolute height of 30 as we don&#8217;t want the menu or status bar to grow or shrink as the window is resized. The 2nd row is set to * so it will use up the remaining space.&nbsp; For the columns we want the 1st column to be roughly 1/4 the width of the 2nd column so we can set up the width attributes to be * and 4* respectively.&nbsp; If you build and run it you will see the basic layout of the app taking shape. Now lets add some controls.</p>
<p><em><font size="3">Add Some Controls</font></em></p>
<p>Adding controls is quite simple with the grid layout we have created.&nbsp; You add the markup for the control you want to add and set its Grid.Column and Grid.Row attributes to tell it where you want it to reside in the grid.&nbsp; Controls that span more than 1 row or column use Grid.ColumnSpan and Grid.RowSpan attributes to define how many it will span (default is 1).&nbsp; </p>
<p>So based on our specifications lets add a menu( row 0 spaning 2 cols), a stack panel(row1, col1), a text box (row 1 col2), a grid splitter( row 1 between col 1 and col2), and a status bar (row 3, spaning 2 cols).&nbsp; Whew thats a long description, as I am getting used to XAML markup it really is remarkable how verbose it is in describing the layout in markup.&nbsp; Here&#8217;s the XAML:</p>
<blockquote><pre class="code"><span style="color:blue;">&lt;</span><span style="color:#a31515;">Grid </span><span style="color:red;">ShowGridLines</span><span style="color:blue;">="True"&gt;
        &lt;</span><span style="color:#a31515;">Grid.RowDefinitions</span><span style="color:blue;">&gt;
            &lt;</span><span style="color:#a31515;">RowDefinition </span><span style="color:red;">Height</span><span style="color:blue;">="30" /&gt;
            &lt;</span><span style="color:#a31515;">RowDefinition </span><span style="color:red;">Height</span><span style="color:blue;">="*" /&gt;
            &lt;</span><span style="color:#a31515;">RowDefinition </span><span style="color:red;">Height</span><span style="color:blue;">="30" /&gt;
        &lt;/</span><span style="color:#a31515;">Grid.RowDefinitions</span><span style="color:blue;">&gt;
        &lt;</span><span style="color:#a31515;">Grid.ColumnDefinitions</span><span style="color:blue;">&gt;
            &lt;</span><span style="color:#a31515;">ColumnDefinition </span><span style="color:red;">Width</span><span style="color:blue;">="1*" /&gt;
            &lt;</span><span style="color:#a31515;">ColumnDefinition </span><span style="color:red;">Width</span><span style="color:blue;">="4*" /&gt;
        &lt;/</span><span style="color:#a31515;">Grid.ColumnDefinitions</span><span style="color:blue;">&gt;
        </span><span style="color:green;">&lt;!-- MENU --&gt;
        </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">Menu </span><span style="color:red;">Grid.ColumnSpan</span><span style="color:blue;">="2"&gt;</span><span style="color:#a31515;">MENU</span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">Menu</span><span style="color:blue;">&gt;
        </span><span style="color:green;">&lt;!-- LEFT PANEL--&gt;
        </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">StackPanel </span><span style="color:red;">Grid.Row</span><span style="color:blue;">="1" </span><span style="color:red;">Margin</span><span style="color:blue;">="15"&gt;&lt;/</span><span style="color:#a31515;">StackPanel</span><span style="color:blue;">&gt;
        </span><span style="color:green;">&lt;!--GRID SPLITTER --&gt;        </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">GridSplitter </span><span style="color:red;">Grid.Column</span><span style="color:blue;">="1" </span><span style="color:red;">Grid.Row</span><span style="color:blue;">="1" </span><span style="color:red;">HorizontalAlignment</span><span style="color:blue;">="Left" </span><span style="color:red;">Width</span><span style="color:blue;">="5" &gt;&lt;/</span><span style="color:#a31515;">GridSplitter</span><span style="color:blue;">&gt;</span><span style="color:green;">        </span><span style="color:green;">&lt;!--RIGHT PANEL--&gt;
        </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">TextBox </span><span style="color:red;">Grid.Row</span><span style="color:blue;">="1" </span><span style="color:red;">Grid.Column</span><span style="color:blue;">="2" </span><span style="color:red;">Margin</span><span style="color:blue;">="15" </span><span style="color:red;">BorderBrush</span><span style="color:blue;">="Black"&gt;</span><span style="color:#a31515;">Main Area</span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">TextBox</span><span style="color:blue;">&gt;
        </span><span style="color:green;">&lt;!--STATUS BAR--&gt;
        </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">StatusBar </span><span style="color:red;">Grid.Row</span><span style="color:blue;">="2" </span><span style="color:red;">Grid.ColumnSpan</span><span style="color:blue;">="2" &gt;</span><span style="color:#a31515;">Status</span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">StatusBar</span><span style="color:blue;">&gt;
    &lt;/</span><span style="color:#a31515;">Grid</span><span style="color:blue;">&gt;</span></pre>
</blockquote>
<p><font color="#008000" size="3"><strong><u><em>New Items</em></u></strong></font> </p>
<p><span style="color:red;">Grid.ColumnSpan<span style="color:blue;">=&#8221;2&#8243;</span> </span>- defines how many columns the control will span staring from its Grid.Column value.&nbsp; In this sample there are 2 columns so it spans the entire grid.</p>
<p><span style="color:red;">Margin</span><span style="color:blue;">=&#8221;#</span>&#8221; &#8211; defines how much space to leave around a control. a single value such as 15 would create a margin of 15 for the left, top,right,bottom. </p>
<p><span style="color:red;">Margin</span><span style="color:blue;">=&#8221;#,#</span>&#8221; &#8211; defines margin where 1st value is left and right and 2nd value is top and bottom</p>
<p><span style="color:red;">Margin</span><span style="color:blue;">=&#8221;#,#,#,#</span>&#8221; &#8211; defines margin going clockwise around control starting with left&nbsp; </p>
<p><span style="color:#a31515;">GridSplitter </span>- set which column and row it belongs to and set its horizontalalignment to place it on that edge of the grid cell and define its width</p>
<p>&nbsp;</p>
<p>Pretty basic but not bad for day 1 of learning WPF.&nbsp; In the next post I&#8217;ll add to this by building a menu structure, adding some expandable control boxes in the left StackPanel and creating some visual styles.</p>
<p>&nbsp;</p>
<p><div class="wlWriterSmartContent" id="scid:18d43e01-4549-4fde-8ca6-c7b4b7385fac:e6ebe5ba-bf18-4254-be93-82f1f7dc3a70" style="display:inline;float:none;margin:0;padding:0;">
<p>Download Solution &#8211; <a href="http://www.dailyworkbreak.com/blogresources/BasicWPFLayoutSample_B8D3/BasicWPFLayoutSample_4.zip">BasicWPFLayoutSample.zip</a></p>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/wpfanswers.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/wpfanswers.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wpfanswers.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wpfanswers.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wpfanswers.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wpfanswers.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/wpfanswers.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/wpfanswers.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/wpfanswers.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/wpfanswers.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wpfanswers.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wpfanswers.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wpfanswers.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wpfanswers.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wpfanswers.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wpfanswers.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wpfanswers.wordpress.com&amp;blog=4585854&amp;post=15&amp;subd=wpfanswers&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://wpfanswers.wordpress.com/2008/08/22/basic-wpf-layout-sample-day-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d6455fe93c0a486d885756a15690e5c9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">wpfanswers</media:title>
		</media:content>

		<media:content url="http://www.dailyworkbreak.com/blogresources/BasicWPFLayoutSample_B8D3/UISkeleton1_thumb.png" medium="image">
			<media:title type="html">UI Skeleton1</media:title>
		</media:content>
	</item>
	</channel>
</rss>
