<?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>ALOMOHORA &#187; Silverlight</title>
	<atom:link href="http://alomohora.com/tag/silverlight/feed/" rel="self" type="application/rss+xml" />
	<link>http://alomohora.com</link>
	<description>All about programming languages</description>
	<lastBuildDate>Tue, 25 Oct 2011 04:27:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Multi Page Silverlight Application</title>
		<link>http://alomohora.com/multi-page-silverlight-application/</link>
		<comments>http://alomohora.com/multi-page-silverlight-application/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 07:31:43 +0000</pubDate>
		<dc:creator>alomohora</dc:creator>
				<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://alomohora.com/?p=1647</guid>
		<description><![CDATA[There are a number of ways of implementing a multi-page Silverlight 2.0 application. Let’s begin by creating a new Silverlight application in Visual Studio (allowing it to create an ASP.NET Web Application Project) named SilverlightNavigation Notice that Visual Studio creates one page, Page.xaml for you by default and that Page.xaml is a UserControl (you can [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">There are a number of ways of implementing a multi-page Silverlight 2.0 application.</p>
<p style="text-align: justify;"><span id="more-1647"></span></p>
<p style="text-align: justify;">Let’s begin by creating a new Silverlight application in Visual Studio (allowing it to create an ASP.NET Web Application Project) named <strong>Silverlight<span>Navigation</span></strong></p>
<p style="text-align: justify;">Notice that Visual Studio creates one page, <strong><span>Page.xaml</span></strong> for you by default and that <strong>Page.xaml </strong>is a UserControl (you can see that by looking at the xaml view of <strong>Page.xaml</strong>).</p>
<p style="text-align: justify;">Add <strong>PageSwitcher.xaml</strong> as you would any other UserControl, but once it is created, take out the grid that Visual Studio creates for you and change the width and height of the UserControl to 300 x 300.</p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">UserControl</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Class</span><span style="color: blue;">=&quot;SilverlightNavigation.PageSwitcher&quot;</span></p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">:</span><span style="color: red;">x</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> Width</span><span style="color: blue;">=&quot;300&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;300&quot;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Grid</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">=&quot;LayoutRoot&quot;</span><span style="color: red;"> Background</span><span style="color: blue;">=&quot;AliceBlue&quot;&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Grid</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: #a31515;">UserControl</span><span style="color: blue;">&gt;</span></p>
</div>
<p style="text-align: justify;">This is the one UserControl that you will leave empty, because we will fill it programmatically with the contents of other pages as we go. It is, in essence, the vessel into which we’ll be pouring each page we want to view.</p>
<p style="text-align: justify;">The core of <strong>PageSwitcher.xaml.cs</strong> is an overloaded Navigate method that takes either a UserControl or a UserControl and an object.</p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">using</span> System;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Collections.Generic;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Linq;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Net;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Controls;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Documents;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Input;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Media;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Media.Animation;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Shapes;</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: blue;">namespace</span> SilverlightNavigation</p>
<p style="margin: 0px;">{</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">PageSwitcher</span> : <span style="color: #2b91af;">UserControl</span></p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> PageSwitcher()</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; InitializeComponent();</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green;">// 1st overload</span></p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">void</span> Navigate(<span style="color: #2b91af;">UserControl</span> nextPage)</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">this</span>.Content = nextPage;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green;">// 2nd overload</span></p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">void</span> Navigate(<span style="color: #2b91af;">UserControl</span> nextPage, <span style="color: blue;">object</span> state)</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">this</span>.Content = nextPage;</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #2b91af;">ISwitchable</span> s = nextPage <span style="color: blue;">as</span> <span style="color: #2b91af;">ISwitchable</span>;</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">if</span> (s != <span style="color: blue;">null</span>)</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; s.UtilizeState(state);</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">else</span></p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">ArgumentException</span>(<span style="color: #a31515;">&quot;nextPage is not ISwitchable! &quot;</span> + nextPage.Name.ToString());</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">}</p>
</div>
<p style="text-align: justify;">The interface is just a promise that any class implementing the interface will implement UtilizeState. UtilizeState is a method that takes an object and returns void.</p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">using</span> System;</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: blue;">namespace</span> SilverlightNavigation</p>
<p style="margin: 0px;">{</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">interface</span> <span style="color: #2b91af;">ISwitchable</span></p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">void</span> UtilizeState(<span style="color: blue;">object</span> state);</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">}</p>
</div>
<p style="text-align: justify;">You create the interface by telling visual studio you want to create a new class named <strong>ISwitchable.cs</strong> and then replacing the class that it creates for you with the interface code shown.</p>
<p style="text-align: justify;">Before we go any further, we must update <strong>App.xaml.cs</strong>. Please replace the contents of <strong>Application_Startup</strong> with the following four lines of code.</p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">private</span> <span style="color: blue;">void</span> Application_Startup(<span style="color: blue;">object</span> sender, StartupEventArgs e)</p>
<p style="margin: 0px;">{</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; PageSwitcher pageSwitcher = <span style="color: blue;">new</span> PageSwitcher();</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">this</span>.RootVisual = pageSwitcher;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; Switcher.pageSwitcher = pageSwitcher;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; Switcher.Switch(<span style="color: blue;">new</span> Page());</p>
<p style="margin: 0px;">}</p>
</div>
<p style="text-align: justify;">Let’s create a very simple body for both <strong>Page.xaml</strong> and <strong>Page2.xaml</strong> to test the mechanism we’ve created.</p>
<p style="text-align: justify;">In Page, add the following <strong>Page.xaml</strong></p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">UserControl</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Class</span><span style="color: blue;">=&quot;SilverlightNavigation.Page&quot;</span></p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">:</span><span style="color: red;">x</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> Width</span><span style="color: blue;">=&quot;300&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;300&quot;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Grid</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">=&quot;LayoutRoot&quot;</span><span style="color: red;"> Background</span><span style="color: blue;">=&quot;AliceBlue&quot;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">TextBlock</span><span style="color: red;"> Text</span><span style="color: blue;">=&quot;Page1&quot;</span><span style="color: red;"> FontSize</span><span style="color: blue;">=&quot;18&quot;</span><span style="color: red;"> HorizontalAlignment</span><span style="color: blue;">=&quot;Center&quot; /&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">=&quot;ButtonPage1&quot;</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Go To Page2&quot;</span><span style="color: red;"> FontSize</span><span style="color: blue;">=&quot;18&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;125&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot; /&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Grid</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: #a31515;">UserControl</span><span style="color: blue;">&gt;</span></p>
</div>
<p style="text-align: justify;">You’ll navigate to this new instance of Page2 through the static Switch method of the Switcher class.</p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">using</span> System;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Collections.Generic;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Linq;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Net;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Controls;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Documents;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Input;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Media;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Media.Animation;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Shapes;</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: blue;">namespace</span> SilverlightNavigation</p>
<p style="margin: 0px;">{</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Page</span> : <span style="color: #2b91af;">UserControl</span></p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> Page()</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; InitializeComponent();</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ButtonPage1.Click += <span style="color: blue;">new</span> <span style="color: #2b91af;">RoutedEventHandler</span>(ButtonPage1_Click);</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">void</span> ButtonPage1_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">RoutedEventArgs</span> e)</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #2b91af;">Switcher</span>.Switch(<span style="color: blue;">new</span> <span style="color: #2b91af;">Page2</span>());</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">}</p>
</div>
<p style="text-align: justify;">In Page, add the following <strong>Page2.xaml</strong></p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">UserControl</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Class</span><span style="color: blue;">=&quot;SilverlightNavigation.Page2&quot;</span></p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">:</span><span style="color: red;">x</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> Width</span><span style="color: blue;">=&quot;300&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;300&quot;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Grid</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">=&quot;LayoutRoot&quot;</span><span style="color: red;"> Background</span><span style="color: blue;">=&quot;AliceBlue&quot;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">TextBlock</span><span style="color: red;"> Text</span><span style="color: blue;">=&quot;Page2&quot;</span><span style="color: red;"> FontSize</span><span style="color: blue;">=&quot;18&quot;</span><span style="color: red;"> HorizontalAlignment</span><span style="color: blue;">=&quot;Center&quot; /&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">=&quot;ButtonPage2&quot;</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Go To Page1&quot;</span><span style="color: red;"> FontSize</span><span style="color: blue;">=&quot;18&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;125&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot; /&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Grid</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: #a31515;">UserControl</span><span style="color: blue;">&gt;</span></p>
</div>
<p style="text-align: justify;">And <strong>Page2.xaml.cs</strong></p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">using</span> System;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Collections.Generic;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Linq;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Net;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Controls;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Documents;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Input;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Media;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Media.Animation;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Shapes;</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: blue;">namespace</span> SilverlightNavigation</p>
<p style="margin: 0px;">{</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Page2</span> : <span style="color: #2b91af;">UserControl</span></p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> Page2()</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; InitializeComponent();</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ButtonPage2.Click += <span style="color: blue;">new</span> <span style="color: #2b91af;">RoutedEventHandler</span>(ButtonPage2_Click);</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">void</span> ButtonPage2_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">RoutedEventArgs</span> e)</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #2b91af;">Switcher</span>.Switch(<span style="color: blue;">new</span> <span style="color: #2b91af;">Page</span>());</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;">}</p>
</div>
<p style="text-align: justify;">Result</p>
<div id="silverlightControlHost" align="center">
		<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="300" height="300"><param name="source" value="http://alomohora.com/wp-silverlight/SilverlightNavigation.xap"/><param name="background" value="white" /><param name="minRuntimeVersion" value="2.0.31005.0" /><param name="enableHtmlAccess" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"><img src="http://makiki.wordpress.com/files/2009/05/silverlightforwordpress.png" alt="Install Microsoft Silverlight" style="border-style: none; width:400px; height:200px"/></a><br />
		</object><br />
		<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
	</div>
<p style="text-align: justify;"><a title="Silverlight Navigation" href="http://www.ziddu.com/download/11176480/SilverlightNavigation.rar.html">Source Code</a></p>
<h4>Incoming search terms for the article:</h4><p style="text-align: justify;"><a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multi page application">silverlight multi page application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multiple pages">silverlight multiple pages</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multi page">silverlight multi page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="multi page silverlight application">multi page silverlight application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight page switcher">silverlight page switcher</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multipage">silverlight multipage</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="multi-page Silverlight application">multi-page Silverlight application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight Switcher">silverlight Switcher</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="PageSwitcher silverlight">PageSwitcher silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight pageswitcher">silverlight pageswitcher</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="page switcher in silverlight">page switcher in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="how to navigate from one xaml page to another xaml page in silverlight">how to navigate from one xaml page to another xaml page in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight application multiple page">silverlight application multiple page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="buliding multiple page silverlight application in asp net codeproject">buliding multiple page silverlight application in asp net codeproject</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multi-page application">silverlight multi-page application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="multipage application in silver light 4">multipage application in silver light 4</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="multipage silverlight application">multipage silverlight application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="designing multipage silverlight application">designing multipage silverlight application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="multiple pages in silverlight">multiple pages in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight next page">silverlight next page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multiple page">silverlight multiple page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="ISWITCHABLE SILVERLIGHT">ISWITCHABLE SILVERLIGHT</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="how to use multiple xaml page in silverlight">how to use multiple xaml page in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="multi page silverlight">multi page silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="how to create multiple page silverlight application">how to create multiple page silverlight application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="multipage application in silverlight">multipage application in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multi page applications">silverlight multi page applications</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight goto page">silverlight goto page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="add user control to page xaml in silverlight">add user control to page xaml in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="multiple usercontrol in xaml silverlight">multiple usercontrol in xaml silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="how to nevigate from one page to user control in silverlight">how to nevigate from one page to user control in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight application with multiple pages">silverlight application with multiple pages</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight application programming multi pages">silverlight application programming multi pages</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multi usercontrol">silverlight multi usercontrol</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="page to page in silverlight">page to page in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="programmatically navigate to another xaml in silverlight navigation project">programmatically navigate to another xaml in silverlight navigation project</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="how to create multiple page in silverlight application">how to create multiple page in silverlight application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="how to create multipage silverlight application">how to create multipage silverlight application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="Implementing Multi pages in Silverlight Applications">Implementing Multi pages in Silverlight Applications</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multiple xaml pages">silverlight multiple xaml pages</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multi xaml">silverlight multi xaml</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="Multi pages in Silverlight Applications Codeproject">Multi pages in Silverlight Applications Codeproject</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="multi page application silverlight">multi page application silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="multi page application in silverlight">multi page application in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="multi-page applications in silverlight">multi-page applications in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="programmatically navigate silverlight">programmatically navigate silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="multi page xaml">multi page xaml</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multiple xaml in single page">silverlight multiple xaml in single page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight click switch to page">silverlight click switch to page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="Iswitchable cs">Iswitchable cs</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight switch usercontrol">silverlight switch usercontrol</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight xaml switch pages samples c">silverlight xaml switch pages samples c</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="application multi pages silverlight 4">application multi pages silverlight 4</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="working with multiple page in silverlight">working with multiple page in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="navigate from one usercontrol xaml to another user control xaml">navigate from one usercontrol xaml to another user control xaml</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="Implementing Multi pages in Silverlight Applications\">Implementing Multi pages in Silverlight Applications\</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="utilizestate(object state)">utilizestate(object state)</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="void UtilizeState(object state);">void UtilizeState(object state);</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight goto page2 xaml">silverlight goto page2 xaml</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight goto page xaml">silverlight goto page xaml</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="what is multi page application in silverlight">what is multi page application in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="what is silverlight user control application class and page">what is silverlight user control application class and page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight go to page2">silverlight go to page2</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight go to page">silverlight go to page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight example multipage application">silverlight example multipage application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight embed usercontrol in page">silverlight embed usercontrol in page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight display multiple pages">silverlight display multiple pages</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="Silverlight how to navigate to a page from usercontrol">Silverlight how to navigate to a page from usercontrol</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight in vs2010 navigation from page to page">silverlight in vs2010 navigation from page to page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight iswitchable">silverlight iswitchable</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multi page business app">silverlight multi page business app</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multi page application using vs 2010">silverlight multi page application using vs 2010</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight multi page application navigation">silverlight multi page application navigation</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="using multiple usercontrol in one xaml">using multiple usercontrol in one xaml</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="using silverlight control in multi application">using silverlight control in multi application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="UtilizeState">UtilizeState</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight login windows on multipage app">silverlight login windows on multipage app</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight login page example">silverlight login page example</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight login navigation">silverlight login navigation</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="utilizeState silverlight">utilizeState silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="utilizestate wpf">utilizestate wpf</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight login">silverlight login</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="what is the namespace of PageSwitcher?">what is the namespace of PageSwitcher?</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="which namespace will use navigate one page to another page in silverlight">which namespace will use navigate one page to another page in silverlight</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight applications multiple user controls">silverlight applications multiple user controls</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight add user control to page">silverlight add user control to page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight add multiple page to a single page">silverlight add multiple page to a single page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight 4 programmatically page navigation">silverlight 4 programmatically page navigation</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight 4 navigate from usercontrol to page">silverlight 4 navigate from usercontrol to page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight 4 multiple pages">silverlight 4 multiple pages</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight 4 muli-page application">silverlight 4 muli-page application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight 4 0 multi page application">silverlight 4 0 multi page application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="wpf multi page application">wpf multi page application</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="wpf UtilizeState">wpf UtilizeState</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="show multiple silverlight applications">show multiple silverlight applications</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="xaml and multiple xaml cs">xaml and multiple xaml cs</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="public void navigate(usercontrol nextpage)">public void navigate(usercontrol nextpage)</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight add usercontrol to page">silverlight add usercontrol to page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight animate go from page to page">silverlight animate go from page to page</a>, <a href="http://alomohora.com/multi-page-silverlight-application/" title="silverlight animation switch page">silverlight animation switch page</a></p>]]></content:encoded>
			<wfw:commentRss>http://alomohora.com/multi-page-silverlight-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrate Media into Silverlight</title>
		<link>http://alomohora.com/integrate-media-into-silverlight/</link>
		<comments>http://alomohora.com/integrate-media-into-silverlight/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 02:12:51 +0000</pubDate>
		<dc:creator>alomohora</dc:creator>
				<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://alomohora.com/?p=1624</guid>
		<description><![CDATA[Silverlight includes support to play audio and video files. It can play Windows Media Video (WMV), Windows Media Audio (WMA) and MP3 files. Adding media to a page is as simple as adding a MediaElement to your markup and providing a Uniform Resource Identifier (URI) to the media to play. The following example creates a [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Silverlight includes support to play audio and video files.</p>
<p style="text-align: justify;"><span id="more-1624"></span></p>
<p style="text-align: justify;">It can play Windows Media Video (WMV), Windows Media Audio (WMA) and MP3 files.</p>
<p style="text-align: justify;">Adding media to a page is as simple as adding a <strong>MediaElement</strong> to your markup and providing a Uniform Resource Identifier (URI) to the media to play. The following example creates a <strong>MediaElement</strong> and sets its <strong>Source</strong> property to the URI of a video file. The <strong>MediaElement</strong> begins playing when the page loads.</p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">MediaElement</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">=&#8221;mediaElement&#8221;</span><span style="color: red;"> Source</span><span style="color: blue;">=&#8221;Bear.wmv&#8221;</span><span style="color: red;"> Width</span><span style="color: blue;">=&#8221;250&#8243;</span><span style="color: red;"> Height</span><span style="color: blue;">=&#8221;250&#8243; </span><span style="color: blue;">/&gt;</span></p>
</div>
<p style="text-align: justify;">We can control media playback by using the <strong>Play</strong>, <strong>Pause</strong>, and <strong>Stop</strong> methods of a <strong>MediaElement</strong> object.</p>
<div id="silverlightControlHost" align="center">
		<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="300" height="300"><param name="source" value="http://alomohora.com/wp-silverlight/SilverlightMedia.xap"/><param name="background" value="white" /><param name="minRuntimeVersion" value="2.0.31005.0" /><param name="enableHtmlAccess" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"><img src="http://makiki.wordpress.com/files/2009/05/silverlightforwordpress.png" alt="Install Microsoft Silverlight" style="border-style: none; width:400px; height:200px"/></a><br />
		</object><br />
		<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
	</div>
<p style="text-align: justify;"><a title="Silverlight Media" href="http://www.ziddu.com/download/11176446/SilverlightMedia.rar.html">Download Code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alomohora.com/integrate-media-into-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight (Layout Management)</title>
		<link>http://alomohora.com/silverlight-layout-management/</link>
		<comments>http://alomohora.com/silverlight-layout-management/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 06:45:46 +0000</pubDate>
		<dc:creator>alomohora</dc:creator>
				<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://alomohora.com/?p=349</guid>
		<description><![CDATA[Silverlight and WPF support a flexible layout management system that enables developers and designers to easily coordinate how controls are positioned within a UI surface. This layout system supports both a fixed position model where controls are positioned using explicit coordinates, as well as a more dynamic position model where layout and controls can be [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Silverlight and WPF support a flexible layout management system that enables developers and designers to easily coordinate how controls are positioned within a UI surface.  This layout system supports both a fixed position model where controls are positioned using explicit coordinates, as well as a more dynamic position model where layout and controls can be automatically sized and flowed as the browser resizes.</p>
<p style="text-align: justify;"><span id="more-349"></span></p>
<p style="text-align: justify;">Developers using Silverlight and WPF use layout panels to coordinate the position and resizing of controls contained within them.  The built-in layout panels in Silverlight 2 include three of the most commonly used ones in WPF:</p>
<ul type="disc">
<li style="text-align: justify;">Canvas</li>
<li style="text-align: justify;">Stack Panel</li>
<li style="text-align: justify;">Grid</li>
</ul>
<p style="text-align: justify;"><strong>Canvas Panel</strong></p>
<p style="text-align: justify;">The Canvas panel is a pretty basic layout panel that supports positioning controls contained within it using explicit coordinates.</p>
<p style="text-align: justify;">You position elements in a Canvas using a XAML feature called &#8220;Attached Properties&#8221; &#8211; which allow you to specify a control&#8217;s position relative to its immediate parent Canvas control&#8217;s Left, Top, Right or Bottom coordinates.  Attached properties are useful as they allow a parent panel to extend the property set of a control contained within it. Canvas, by defining an attached property for “Top” and ”Left” basically adds the ability to define left and top attachment on Button (or any other UI element that is added to the Canvas), without any need to actually add a property to the Button class, or modify the Button class in any way.</p>
<p style="text-align: justify;">We could add two buttons to a Canvas container, and position them both 50 pixels from the left of the Canvas, and 50 and 150 pixels from the top using XAML like below (the Canvas.Left and Canvas.Top attributes are examples of the attached property syntax):</p>
<p style="text-align: center;"><a title="layout-management1" href="http://makiki.files.wordpress.com/2009/02/alomohora-silverlight-layout-management1.jpg"><img class="size-medium wp-image-350 aligncenter" title="Alomohora - Silverlight - Layout Management1" src="http://makiki.files.wordpress.com/2009/02/alomohora-silverlight-layout-management1.jpg?w=300&amp;h=100" alt="Alomohora - Silverlight - Layout Management1" width="300" height="100" /></a></p>
<p style="text-align: justify;">The code</p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">UserControl</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Class</span><span style="color: blue;">=&quot;SilverlightSample.Page&quot;</span></p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">:</span><span style="color: red;">x</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> Width</span><span style="color: blue;">=&quot;300&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;300&quot;&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Canvas</span><span style="color: red;"> Background</span><span style="color: blue;">=&quot;#FF5C7590&quot;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Button1&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;100&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Canvas.Left</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Canvas.Top</span><span style="color: blue;">=&quot;50&quot;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Button2&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;100&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Canvas.Left</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Canvas.Top</span><span style="color: blue;">=&quot;150&quot;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Canvas</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: #a31515;">UserControl</span><span style="color: blue;">&gt;</span></p>
</div>
<p style="text-align: justify;">This would then render our buttons like below:</p>
<div id="silverlightControlHost" align="center">
	<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="300" height="300"><param name="source" value="http://alomohora.com/wp-silverlight/SilverlightApplicationCanvas.xap"/><param name="background" value="white" /><param name="minRuntimeVersion" value="2.0.31005.0" /><param name="enableHtmlAccess" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"><img src="http://makiki.wordpress.com/files/2009/05/silverlightforwordpress.png" alt="Install Microsoft Silverlight" style="border-style: none; width:400px; height:200px"/></a><br />
	</object></p>
<p>	<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
</div>
<p style="text-align: justify;"><a href="http://www.ziddu.com/download/11176547/SilverlightSample%20-%20Canvas%20Panel.zip.html">Download source code for Canvas Panel</a></p>
<p style="text-align: justify;">While the Canvas is useful for scenarios where the UI elements contained within it never move, it tends not to be very flexible as you add more controls into it or handle scenarios where the UI needs to resize or move. In cases like these you end up having to manually write code yourself to move things around inside the Canvas (which is a pain). A better solution for these dynamic scenarios is typically to use an alternative layout panel that has built-in semantics to-do this for you &#8211; like the StackPanel and Grid.</p>
<p style="text-align: justify;"><strong>StackPanel</strong></p>
<p style="text-align: justify;">The StackPanel control is a simple layout panel that supports positioning its contained controls in either a row or column layout.  StackPanels are typically used in scenarios where you want to arrange a small subsection of the UI on your page.</p>
<p style="text-align: justify;">For example, we could use the StackPanel to vertically arrange three buttons on our page using XAML markup like below:</p>
<p style="text-align: center;"><a title="layout-management3" href="http://makiki.files.wordpress.com/2009/02/alomohora-silverlight-layout-management3.jpg"><img class="size-medium wp-image-357 aligncenter" title="Alomohora - Silverlight - Layout Management3" src="http://makiki.files.wordpress.com/2009/02/alomohora-silverlight-layout-management3.jpg?w=300&amp;h=145" alt="Alomohora - Silverlight - Layout Management3" width="300" height="145" /></a></p>
<p style="text-align: justify;">The code</p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">UserControl</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Class</span><span style="color: blue;">=&quot;SilverlightSample.Page&quot;</span></p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">:</span><span style="color: red;">x</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> Width</span><span style="color: blue;">=&quot;400&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;300&quot;&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">StackPanel</span><span style="color: red;"> Background</span><span style="color: blue;">=&quot;#FF5C7590&quot;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Button1&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;100&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Margin</span><span style="color: blue;">=&quot;10&quot;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Button2&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;100&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Margin</span><span style="color: blue;">=&quot;10&quot;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Button3&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;100&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Margin</span><span style="color: blue;">=&quot;10&quot;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">StackPanel</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: #a31515;">UserControl</span><span style="color: blue;">&gt;</span></p>
</div>
<p style="text-align: justify;">At runtime the StackPanel would then automatically arrange the Button controls in a vertical stack for us like below:</p>
<div id="silverlightControlHost" align="center">
	<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="300" height="300"><param name="source" value="http://alomohora.com/wp-silverlight/SilverlightApplicationStackPanel.xap"/><param name="background" value="white" /><param name="minRuntimeVersion" value="2.0.31005.0" /><param name="enableHtmlAccess" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"><img src="http://makiki.wordpress.com/files/2009/05/silverlightforwordpress.png" alt="Install Microsoft Silverlight" style="border-style: none; width:400px; height:200px"/></a><br />
	</object></p>
<p>	<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
</div>
<p style="text-align: justify;"><a href="http://www.ziddu.com/download/11176556/SilverlightSample%20-%20StackPanel.zip.html">Download source code for Stack Panel</a></p>
<p style="text-align: justify;">We could alternatively set the &#8220;Orientation&#8221; property of the StackPanel to be &#8220;Horizontal&#8221; instead of Vertical (which is the default):</p>
<p style="text-align: center;"><a title="layout-management5" href="http://makiki.files.wordpress.com/2009/02/alomohora-silverlight-layout-management5.jpg"><img class="size-medium wp-image-354 aligncenter" title="Alomohora - Silverlight - Layout Management5" src="http://makiki.files.wordpress.com/2009/02/alomohora-silverlight-layout-management5.jpg?w=300&amp;h=145" alt="Alomohora - Silverlight - Layout Management5" width="269" height="300" /></a></p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">UserControl</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Class</span><span style="color: blue;">=&quot;SilverlightSample.Page&quot;</span></p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">:</span><span style="color: red;">x</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> Width</span><span style="color: blue;">=&quot;400&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;300&quot;&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">StackPanel</span><span style="color: red;"> Orientation</span><span style="color: blue;">=&quot;Horizontal&quot;</span><span style="color: red;"> Background</span><span style="color: blue;">=&quot;#FF5C7590&quot;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Button1&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;100&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Margin</span><span style="color: blue;">=&quot;10&quot;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Button2&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;100&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Margin</span><span style="color: blue;">=&quot;10&quot;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Button3&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;100&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Margin</span><span style="color: blue;">=&quot;10&quot;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">StackPanel</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: #a31515;">UserControl</span><span style="color: blue;">&gt;</span></p>
</div>
<p style="text-align: justify;">This will then cause the StackPanel to automatically arrange the Button controls in a horizontal row like below:</p>
<div align="center">
<div id="silverlightControlHost">
		<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="300" height="300"><param name="source" value="http://alomohora.com/wp-silverlight/SilverlightApplicationStackPanelOrientation.xap"/><param name="background" value="white" /><param name="minRuntimeVersion" value="2.0.31005.0" /><param name="enableHtmlAccess" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"><br />
				<img src="http://storage.timheuer.com/sl4wp-ph.png" alt="Install Microsoft Silverlight" style="border-style: none; width:400px; height:200px"/><br />
			</a><br />
		</object></p>
<p>		<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
	</div>
<p>
</div>
<p style="text-align: justify;"><a href="http://www.ziddu.com/download/11176570/SilverlightSample%20-%20StackPanel%20(Orientation).zip.html">Download source code for Stack Panel (Orientation)</a></p>
<p style="text-align: justify;"><strong>Grid Panel</strong></p>
<p style="text-align: justify;">The Grid control is the most flexible layout panel, and supports arranging controls in multi-row and multi-column layouts.  It is conceptually similar to an HTML Table element.</p>
<p style="text-align: justify;">Unlike an HTML Table, you don&#8217;t embed controls within column and row elements.  Instead you specify a Grid&#8217;s Row and Column definitions using &lt;Grid.RowDefinitions&gt; and &lt;Grid.ColumnDefinitions&gt; properties that are declared immediately under the &lt;Grid&gt; control.  You can then use the XAML &#8220;Attached Property&#8221; syntax on controls contained within the grid to indicate which Grid row and column they should be populated within.</p>
<p style="text-align: justify;">For example, we could declare a Grid layout has three rows and three columns, and then position 4 buttons within it using XAML like below:</p>
<p style="text-align: center;"><a title="layout-management7" href="http://makiki.files.wordpress.com/2009/02/alomohora-silverlight-layout-management7.jpg"><img class="size-medium wp-image-355 aligncenter" title="Alomohora - Silverlight - Layout Management7" src="http://makiki.files.wordpress.com/2009/02/alomohora-silverlight-layout-management7.jpg?w=269&amp;h=300" alt="Alomohora - Silverlight - Layout Management7" width="300" height="196" /></a></p>
<p style="text-align: justify;">The code</p>
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">UserControl</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Class</span><span style="color: blue;">=&quot;SilverlightSample.Page&quot;</span></p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> xmlns</span><span style="color: blue;">:</span><span style="color: red;">x</span><span style="color: blue;">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span> </p>
<p style="margin: 0px;">&nbsp;&nbsp; <span style="color: red;"> Width</span><span style="color: blue;">=&quot;400&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;300&quot;&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Grid</span><span style="color: red;"> Background</span><span style="color: blue;">=&quot;#FF5C7590&quot;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Grid.RowDefinitions</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">RowDefinition</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;60&quot; /&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">RowDefinition</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;60&quot; /&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">RowDefinition</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;60&quot; /&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Grid.RowDefinitions</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Grid.ColumnDefinitions</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">ColumnDefinition</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;110&quot;/&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">ColumnDefinition</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;110&quot;/&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">ColumnDefinition</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;110&quot;/&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Grid.ColumnDefinitions</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Button1&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;100&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Grid.Column</span><span style="color: blue;">=&quot;1&quot;</span><span style="color: red;"> Grid.Row</span><span style="color: blue;">=&quot;0&quot;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Button1&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;100&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Grid.Column</span><span style="color: blue;">=&quot;2&quot;</span><span style="color: red;"> Grid.Row</span><span style="color: blue;">=&quot;1&quot;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Button1&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;100&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Grid.Column</span><span style="color: blue;">=&quot;0&quot;</span><span style="color: red;"> Grid.Row</span><span style="color: blue;">=&quot;1&quot;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;Button1&quot;</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;100&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;50&quot;</span><span style="color: red;"> Grid.Column</span><span style="color: blue;">=&quot;1&quot;</span><span style="color: red;"> Grid.Row</span><span style="color: blue;">=&quot;2&quot;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Grid</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: #a31515;">UserControl</span><span style="color: blue;">&gt;</span></p>
</div>
<p style="text-align: justify;">The Grid layout panel would then position the Button elements for us like so:</p>
<div id="silverlightControlHost" align="center">
	<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="300" height="300"><param name="source" value="http://alomohora.com/wp-silverlight/SilverlightApplicationStackPanelOrientation.xap"/><param name="background" value="white" /><param name="minRuntimeVersion" value="2.0.31005.0" /><param name="enableHtmlAccess" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"><img src="http://makiki.wordpress.com/files/2009/05/silverlightforwordpress.png" alt="Install Microsoft Silverlight" style="border-style: none; width:400px; height:200px"/></a><br />
	</object></p>
<p>	<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
</div>
<p style="text-align: justify;"><a href="http://www.ziddu.com/download/11176571/SilverlightSample%20-%20Grid%20Panel.zip.html">Download source code for Grid Panel</a></p>
<p style="text-align: justify;">n addition to supporting absolute sizing (for example: Height=&#8221;60&#8243;) the Grid&#8217;s RowDefinition and ColumnDefinition controls also support an AutoSizing mode (Height=&#8221;Auto&#8221;), which automatically sizes the Grid or Row based on the size of the content contained within it (you can also optionally specify maximum and minimum size constraints &#8211; which can be very useful).</p>
<p style="text-align: justify;">The Grid&#8217;s Row and ColumnDefinitions also support a feature called &#8220;Proportional Sizing&#8221; &#8211; which enables the size of a Grid&#8217;s Rows and Columns to be spaced proportionally relative to each other (for example: you could have the second row grow at 2x the rate of the first one).</p>
<p style="text-align: justify;">You&#8217;ll find that the Grid provides a ton of power and flexibility &#8211; and it will probably be the most common layout panel control you&#8217;ll end up using.</p>
<h4>Incoming search terms for the article:</h4><p style="text-align: justify;"><a href="http://alomohora.com/silverlight-layout-management/" title="silverlight layout management">silverlight layout management</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="GridPanel Delphi">GridPanel Delphi</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight move canvas based on content">silverlight move canvas based on content</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight dynamic layout arrange browser">silverlight dynamic layout arrange browser</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="Silverlight UI Layout">Silverlight UI Layout</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight layout panels">silverlight layout panels</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight layout manager">silverlight layout manager</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="layout management silverlight">layout management silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight grid with horizontal rows">silverlight grid with horizontal rows</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight layout">silverlight layout</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight grid with dynamic height size">silverlight grid with dynamic height size</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight layout bottom">silverlight layout bottom</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight grid layout position elements">silverlight grid layout position elements</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight grid get top left position">silverlight grid get top left position</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight grid elements">silverlight grid elements</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight get top left of ui element without margin">silverlight get top left of ui element without margin</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight auto resize controls">silverlight auto resize controls</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight button fixed position">silverlight button fixed position</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight canvas top attribute">silverlight canvas top attribute</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight change location of control in code">silverlight change location of control in code</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight control move/resize attach property#">silverlight control move/resize attach property#</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight control three panel">silverlight control three panel</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight coordinates canvas">silverlight coordinates canvas</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight dynamic panel">silverlight dynamic panel</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight fixed control position">silverlight fixed control position</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight flexible layout">silverlight flexible layout</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="Silverlight Get Position of dyamic button">Silverlight Get Position of dyamic button</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="Silverlight layout cause">Silverlight layout cause</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight layout control">silverlight layout control</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight set height auto">silverlight set height auto</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight stackpanel bottom attached to grid">silverlight stackpanel bottom attached to grid</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight stackpanel proportional">silverlight stackpanel proportional</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight stunning UI#">silverlight stunning UI#</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight usercontrol move grid">silverlight usercontrol move grid</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight usercontrol position bottom">silverlight usercontrol position bottom</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="usercontrol cause arrange silverlight">usercontrol cause arrange silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="what is move silverlight control relative to other control">what is move silverlight control relative to other control</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="WPF alternative layout">WPF alternative layout</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight postion relative to other control">silverlight postion relative to other control</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight position on the bottom of canvas">silverlight position on the bottom of canvas</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight layout example">silverlight layout example</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight listboxdragdroptarget grid">silverlight listboxdragdroptarget grid</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight layout panel from code">silverlight layout panel from code</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight layout with user control">silverlight layout with user control</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight layoutcontrol with autosized content">silverlight layoutcontrol with autosized content</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight move control">silverlight move control</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight moving stackpanel">silverlight moving stackpanel</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight panel move">silverlight panel move</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="silverlight pixels coordinates">silverlight pixels coordinates</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="wpf flexible layout with grid">wpf flexible layout with grid</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="3 column layout in siverlight">3 column layout in siverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="find bottom coordinate silverlight">find bottom coordinate silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="fix position control on right bottom of browser silverlight">fix position control on right bottom of browser silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="fixed position elements silverlight">fixed position elements silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="fixed position layout in silverlight">fixed position layout in silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="flexible width layout in silverlight">flexible width layout in silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="get control row and column coordinates in canvas silverlight">get control row and column coordinates in canvas silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="get left top parent canvas xaml">get left top parent canvas xaml</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="google silverlight layout">google silverlight layout</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="grid panel silvelight">grid panel silvelight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="gridlayout panel alternate column background wpf">gridlayout panel alternate column background wpf</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="elements inside a coordinate in silverlight">elements inside a coordinate in silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="communication between different dynamically loaded xaps#sclient=psy-ab">communication between different dynamically loaded xaps#sclient=psy-ab</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="adding a canvas control insside a grid silverlight">adding a canvas control insside a grid silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="arrange control at runtime in stackpanel">arrange control at runtime in stackpanel</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="attach ui element to canvas">attach ui element to canvas</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="attached properties silverlight">attached properties silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="auto adjust the relative position of component in layout silverlight">auto adjust the relative position of component in layout silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="auto arrange panel in silverlight">auto arrange panel in silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="better silverlight wpf layout paanel">better silverlight wpf layout paanel</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="canvas background samples using xaml">canvas background samples using xaml</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="canvas ou grid resize silverlight">canvas ou grid resize silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="ColumnDefinition Proportional Sizing">ColumnDefinition Proportional Sizing</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="#FF5C7590">#FF5C7590</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="how get uielement from silverlight grid layout">how get uielement from silverlight grid layout</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="moving controls silverlight canvas">moving controls silverlight canvas</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="page layout management in silverlight">page layout management in silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="pixel to layout coordinates silverlight">pixel to layout coordinates silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="PollingDuplexBindingElement#">PollingDuplexBindingElement#</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="position control right bottom browser silverlight">position control right bottom browser silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="presentation three columns">presentation three columns</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="proportional panel silverlight">proportional panel silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="proportional stakpanel">proportional stakpanel</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="resizable panel silverlight canvas">resizable panel silverlight canvas</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="runtime layout management in silverlight">runtime layout management in silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="moving control canvas silverlight">moving control canvas silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="moving a button in a grid in silverlight">moving a button in a grid in silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="how to get button canvas silverlight">how to get button canvas silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="how to move the stackpanel from bottom to top in silverlight">how to move the stackpanel from bottom to top in silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="how to size margins proportionally silverlight">how to size margins proportionally silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="layout management xaml">layout management xaml</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="layout positioning sizeing in silverlight">layout positioning sizeing in silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="layout properties silverlight">layout properties silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="layout UserControl width height 100% silverlight">layout UserControl width height 100% silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="most used silverlight layout">most used silverlight layout</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="move grid layout to browser screen top position in silverlight">move grid layout to browser screen top position in silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="move panel in silverlight">move panel in silverlight</a>, <a href="http://alomohora.com/silverlight-layout-management/" title="set ListBoxDragDropTarget Grid Column from codeBehind#">set ListBoxDragDropTarget Grid Column from codeBehind#</a></p>]]></content:encoded>
			<wfw:commentRss>http://alomohora.com/silverlight-layout-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tooltip for Silverlight</title>
		<link>http://alomohora.com/tooltip-for-silverlight/</link>
		<comments>http://alomohora.com/tooltip-for-silverlight/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 06:23:00 +0000</pubDate>
		<dc:creator>alomohora</dc:creator>
				<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://alomohora.com/?p=1508</guid>
		<description><![CDATA[Silverlight offers a class called “ToolTipService” which can be used to display tooltips for Silverlight controls. This class can be attached to most of the UI elements in Silverlight to display tooltips. The below sample code shows how to display a simple text tooltip for a Button control: &#160;&#160;&#160; &#60;Grid x:Name=&#34;LayoutRoot&#34; Background=&#34;White&#34;&#62; &#160;&#160;&#160; &#160;&#160;&#160; &#60;Button [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Silverlight offers a class called “ToolTipService” which can be used to display tooltips for Silverlight controls. This class can be attached to most of the UI elements in Silverlight to display tooltips.</p>
<p style="text-align: justify;"><span id="more-1508"></span></p>
<p style="text-align: justify;">The below sample code shows how to display a simple text tooltip for a Button control:</p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Grid</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">=&quot;LayoutRoot&quot;</span><span style="color: red;"> Background</span><span style="color: blue;">=&quot;White&quot;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> Width</span><span style="color: blue;">=&quot;80&quot;</span><span style="color: red;"> Height</span><span style="color: blue;">=&quot;40&quot;</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;My Button&quot;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">ToolTipService.ToolTip</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">ToolTip</span><span style="color: red;"> Content</span><span style="color: blue;">=&quot;This is tool tip for Button&quot;&gt;&lt;/</span><span style="color: #a31515;">ToolTip</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">ToolTipService.ToolTip</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Grid</span><span style="color: blue;">&gt;</span></p>
<p style="text-align: justify;">And the result</p>
<div id="silverlightControlHost" align="center">
		<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="300" height="300"><param name="source" value="http://alomohora.com/wp-silverlight/SilverlightTooltip.xap"/><param name="background" value="white" /><param name="minRuntimeVersion" value="2.0.31005.0" /><param name="enableHtmlAccess" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"><img src="http://makiki.wordpress.com/files/2009/05/silverlightforwordpress.png" alt="Install Microsoft Silverlight" style="border-style: none; width:400px; height:200px"/></a><br />
		</object><br />
		<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
	</div>
<p></br></p>
<h4>Incoming search terms for the article:</h4><p style="text-align: justify;"><a href="http://alomohora.com/tooltip-for-silverlight/" title="silverlight grid with tooltip">silverlight grid with tooltip</a></p>]]></content:encoded>
			<wfw:commentRss>http://alomohora.com/tooltip-for-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight (Creating Hello World)</title>
		<link>http://alomohora.com/silverlight-creating-hello-world/</link>
		<comments>http://alomohora.com/silverlight-creating-hello-world/#comments</comments>
		<pubDate>Sat, 15 Nov 2008 03:05:22 +0000</pubDate>
		<dc:creator>alomohora</dc:creator>
				<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://alomohora.com/?p=305</guid>
		<description><![CDATA[These tutorials are helping explain some of the core programming concepts of Silverlight. We&#8217;ll start our SilverlightSample application by selecting the File -&#62; New Project menu item within Visual Studio 2008 or Visual Web Developer 2008 Express (which is free) and use the New Project dialog to create a SilverlightSample (note: you will need to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify">These tutorials are helping explain some of the core programming concepts of Silverlight.</p>
<p style="text-align: justify;"><span id="more-305"></span></p>
<p style="text-align: justify">We&#8217;ll start our SilverlightSample application by selecting the <strong>File -&gt; New Project</strong> menu item within Visual Studio 2008 or Visual Web Developer 2008 Express (which is free) and use the <strong>New Project</strong> dialog to create a <strong>SilverlightSample</strong> (note: you will need to download and <a href="http://alomohora.com/silverlight-get-started/">install the Silverlight Tools</a> for VS 2008 release to get this support).</p>
<p style="text-align: center"><a title="Silverlight Hello World" href="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world1.jpg"><img class="aligncenter" title="Alomohora - Silverlight - Creating Hello World1" src="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world1.jpg?w=300&amp;h=206" alt="Alomohora - Silverlight - Creating Hello World1" width="300" height="206" /></a></p>
<p style="text-align: justify">We&#8217;ll name the project <strong>SilverlightSample</strong>.  When we click the <strong>OK</strong> button Visual Studio will prompt us with an additional dialog that allows us to choose whether we want to create just a Silverlight Application project, or optionally also add a server-side ASP.NET Web project to our solution to host the Silverlight Application within.  For this sample we&#8217;ll choose to add an <strong>ASP.NET Web Application project</strong> to the solution as well and name it <strong>SilverlightSample.Web</strong>.</p>
<p style="text-align: center"><a title="Silverlight Hello World" href="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world2.jpg"><img class="aligncenter" title="Alomohora - Silverlight - Creating Hello World2" src="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world2.jpg?w=300&amp;h=270" alt="Alomohora - Silverlight - Creating Hello World2" width="300" height="270" /></a></p>
<p style="text-align: justify">When we click <strong>OK</strong> Visual Studio will create a solution for us that have both a Silverlight client application and an ASP.NET web server application in it.</p>
<p style="text-align: center"><a title="Silverlight Hello World" href="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world3.jpg"><img class="aligncenter" title="Alomohora - Silverlight - Creating Hello World3" src="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world3.jpg?w=261&amp;h=279" alt="Alomohora - Silverlight - Creating Hello World3" width="261" height="279" /></a></p>
<p style="text-align: justify">Right now our <strong>SilverlightSample</strong> application doesn&#8217;t do anything, and when it is run it brings up an empty page. We can change this by opening up the <strong>Page.xaml</strong> file in the project and adding some content to it.</p>
<p style="text-align: center"><a title="Silverlight Hello World" href="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world4.jpg"><img class="aligncenter" title="Alomohora - Silverlight - Creating Hello World4" src="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world4.jpg?w=300&amp;h=216" alt="Alomohora - Silverlight - Creating Hello World4" width="300" height="216" /></a></p>
<p style="text-align: justify">We&#8217;ll begin by changing the background of the grid and by declaring a Button control within it.  We&#8217;ll give the button an <strong>x:Name</strong> attribute value of <strong>MyButton</strong> &#8211; which will allow us to programmatically reference it within our code-behind class.  We&#8217;ll also set its Content, Width and Height properties.</p>
<p style="text-align: center"><a title="Silverlight Hello World" href="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world5.jpg"><img class="aligncenter" title="Alomohora - Silverlight - Creating Hello World5" src="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world5.jpg?w=300&amp;h=103" alt="Alomohora - Silverlight - Creating Hello World5" width="300" height="103" /></a></p>
<p style="text-align: justify">When we run the application our button will then show up in the middle of the page with <strong>Push Me</strong> content text like below.</p>
<p style="text-align: center"><a title="Silverlight Hello World" href="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world6.jpg"><img class="aligncenter" title="Alomohora - Silverlight - Creating Hello World6" src="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world6.jpg?w=300&amp;h=216" alt="Alomohora - Silverlight - Creating Hello World6" width="300" height="216" /></a></p>
<p style="text-align: justify">To add behavior to our button we can add a <strong>Click</strong> event handler to it.  We can do this in source view by typing the event name.</p>
<p style="text-align: center"><a title="Silverlight Hello World" href="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world7.jpg"><img class="aligncenter" title="Alomohora - Silverlight - Creating Hello World7" src="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world7.jpg?w=300&amp;h=88" alt="Alomohora - Silverlight - Creating Hello World7" width="300" height="88" /></a></p>
<p style="text-align: justify">This will then prompt us for the <strong>event handler</strong> in our code-behind class to use.</p>
<p style="text-align: center"><a title="Silverlight Hello World" href="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world8.jpg"><img class="aligncenter" title="Alomohora - Silverlight - Creating Hello World8" src="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world8.jpg?w=300&amp;h=32" alt="Alomohora - Silverlight - Creating Hello World8" width="300" height="32" /></a></p>
<p style="text-align: justify">We can then either type a new event handler method name to use, or optionally just press the enter key to name the event handler method using the default naming convention.</p>
<p style="text-align: center"><a title="Silverlight Hello World" href="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world9.jpg"><img class="aligncenter" title="Alomohora - Silverlight - Creating Hello World9" src="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world9.jpg?w=300&amp;h=18" alt="Alomohora - Silverlight - Creating Hello World9" width="300" height="18" /></a></p>
<p style="text-align: justify">This is full code:</p>
<p style="text-align: justify">
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">UserControl</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Class</span><span style="color: blue;">=&#8221;SilverlightSample.Page&#8221;</span></p>
<p style="margin: 0px;"><span style="color: red;"> xmlns</span><span style="color: blue;">=&#8221;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;</span></p>
<p style="margin: 0px;"><span style="color: red;"> xmlns</span><span style="color: blue;">:</span><span style="color: red;">x</span><span style="color: blue;">=&#8221;http://schemas.microsoft.com/winfx/2006/xaml&#8221;</span></p>
<p style="margin: 0px;"><span style="color: red;"> Width</span><span style="color: blue;">=&#8221;400&#8243;</span><span style="color: red;"> Height</span><span style="color: blue;">=&#8221;300&#8243;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;"> </span><span style="color: blue;">&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #a31515;">Grid</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">=&#8221;LayoutRoot&#8221;</span><span style="color: red;"> Background</span><span style="color: blue;">=&#8221;White&#8221;&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Button</span><span style="color: red;"> x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">=&#8221;MyButton&#8221;</span><span style="color: red;"> Content</span><span style="color: blue;">=&#8221;Push Me!&#8221;</span><span style="color: red;"> Width</span><span style="color: blue;">=&#8221;100&#8243;</span><span style="color: red;"> Height</span><span style="color: blue;">=&#8221;50&#8243;</span><span style="color: red;"> Click</span><span style="color: blue;">=&#8221;MyButton_Click&#8221;&gt;&lt;/</span><span style="color: #a31515;">Button</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: #a31515;"> &nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Grid</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: #a31515;">UserControl</span><span style="color: blue;">&gt;</span></p>
</div>
<p style="text-align: justify">VS will then automatically create a stub event handler implementation in our code-behind class file.  We can use this event handler to update the Button&#8217;s content with a new message when it is clicked.</p>
<p style="text-align: center"><a title="Silverlight Hello World" href="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world10.jpg"><img class="aligncenter" title="Alomohora - Silverlight - Creating Hello World10" src="http://makiki.files.wordpress.com/2009/01/alomohora-silverlight-creating-hello-world10.jpg?w=300&amp;h=216" alt="Alomohora - Silverlight - Creating Hello World10" width="300" height="216" /></a></p>
<p style="text-align: justify">This is full code:</p>
<p style="text-align: justify">
<div style="font-family: Courier New; font-size: 8pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: blue;">using</span> System;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Collections.Generic;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Linq;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Net;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Controls;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Documents;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Input;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Media;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Media.Animation;</p>
<p style="margin: 0px;"><span style="color: blue;">using</span> System.Windows.Shapes;</p>
<p style="margin: 0px;">
<p style="margin: 0px;"><span style="color: blue;">namespace</span> SilverlightSample</p>
<p style="margin: 0px;">{</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Page</span> : <span style="color: #2b91af;">UserControl</span></p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp;{</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span> Page()</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InitializeComponent();</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p style="margin: 0px;">&nbsp;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">private</span> <span style="color: blue;">void</span> MyButton_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">RoutedEventArgs</span> e)</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyButton.Content = <span style="color: #a31515;">&#8220;Pushed&#8221;</span>;</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p style="margin: 0px;">&nbsp;&nbsp;&nbsp;}</p>
<p style="margin: 0px;">}</p>
</div>
<p style="text-align: justify;">After making the change above us can re-run the application and push the button again, and now its content is updated with a <strong>Pushed!</strong> Message.</p>
<div id="silverlightControlHost" align="center">
	<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="300" height="300"><param name="source" value="http://alomohora.com/wp-silverlight/SilverlightHelloWorld.xap"/><param name="background" value="white" /><param name="minRuntimeVersion" value="2.0.31005.0" /><param name="enableHtmlAccess" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"><img src="http://makiki.wordpress.com/files/2009/05/silverlightforwordpress.png" alt="Install Microsoft Silverlight" style="border-style: none; width:400px; height:200px"/></a><br />
	</object></p>
<p>	<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
</div>
<p style="text-align: justify"><a href="http://www.ziddu.com/download/11176273/Silverlight%20-%20Creating%20Hello%20World.zip.html">Download source code</a></p>
<h4>Incoming search terms for the article:</h4><p style="text-align: justify;"><a href="http://alomohora.com/silverlight-creating-hello-world/" title="??? ?????????? zeoslib ?? delphi xe">??? ?????????? zeoslib ?? delphi xe</a>, <a href="http://alomohora.com/silverlight-creating-hello-world/" title="componente zeos para delphi xe2">componente zeos para delphi xe2</a>, <a href="http://alomohora.com/silverlight-creating-hello-world/" title="creating hello world in silverlight">creating hello world in silverlight</a>, <a href="http://alomohora.com/silverlight-creating-hello-world/" title="delphi xe2 zeosdbo">delphi xe2 zeosdbo</a>, <a href="http://alomohora.com/silverlight-creating-hello-world/" title="instalar zeoslib en delphi xe2">instalar zeoslib en delphi xe2</a>, <a href="http://alomohora.com/silverlight-creating-hello-world/" title="zeos xe2">zeos xe2</a>, <a href="http://alomohora.com/silverlight-creating-hello-world/" title="zeoslib xe2">zeoslib xe2</a></p>]]></content:encoded>
			<wfw:commentRss>http://alomohora.com/silverlight-creating-hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

