SilverlightShow: Using the StackPanel control in Silverlight Comments http://www.silverlightshow.net/ Silverlight articles, Silverlight tutorials, Silverlight videos, Silverlight samples SilverlightShow.net http://www.rssboard.org/rss-specification Argotic Syndication Framework 2008.0.2.0, http://www.codeplex.com/Argotic en-US estoychev@completit.com (Emil Stoychev) RE: Using the StackPanel control in Silverlight Very useful article and easy to understand....Thank you...... http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx#comment5955 Pragati http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx Thu, 21 Apr 2011 14:21:56 GMT RE: Using the StackPanel control in Silverlight 2 Beta 1 Thanks, it is useful for me http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx#comment3701 Doan Huynh http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx Wed, 02 Jun 2010 10:50:18 GMT RE: Using the StackPanel control in Silverlight 2 Beta 1 Thank you for this tutorials http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx#comment3495 Kareem http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx Sun, 25 Apr 2010 00:06:03 GMT RE: Using the StackPanel control in Silverlight 2 Beta 1 Thank u very much. http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx#comment2527 kabul_hussain@infosys.com http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx Fri, 09 Oct 2009 17:00:07 GMT RE: Using the StackPanel control in Silverlight 2 Beta 1 very useful article for newbies. http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx#comment2233 Nabeel http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx Wed, 12 Aug 2009 14:26:11 GMT RE: Using the StackPanel control in Silverlight 2 Beta 1 <p>You're welcome ;)</p> http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx#comment966 Enrai http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx Tue, 27 Jan 2009 07:03:38 GMT Using the StackPanel control in Silverlight 2 Beta 1 <p>Thanks</p> http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx#comment953 Sasko http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx Sun, 25 Jan 2009 19:44:33 GMT RE: Using the StackPanel control in Silverlight 2 Beta 1 <p>If you want to do this using a StackPanel you must set the width of the three buttons to fixed values, calculating how much has left for the middle one, because it's not possible a control to take all the available width in a StackPanel with horizontal orientation. The StackPanel uses so much space for a control as it needs, for example the width of the button, if not set, depends on the lenght of its content, an empty Grid control is not displayed. The same goes for the height and the vertical oriented StackPanel. And I think that's a correct behavior, because the controls are placed one after another in the stack and after the second button is placed how can its width be determined when there are othere controls on the line waiting to be placed in the panel. But there is a Layout control that will do this job for you - the Grid control. You can use a grid with 3 columns and one row like this one:</p> <div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: rgb(0, 0, 255);"> <</span><span style="color: rgb(128, 0, 0);">Grid</span> <span style="color: rgb(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">="Black"</span> <span style="color: rgb(255, 0, 0);">Width</span><span style="color: rgb(0, 0, 255);">="400"</span> <span style="color: rgb(255, 0, 0);">Height</span><span style="color: rgb(0, 0, 255);">="300"</span><span style="color: rgb(0, 0, 255);">></span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Grid.ColumnDefinitions</span><span style="color: rgb(0, 0, 255);">></span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">ColumnDefinition</span> <span style="color: rgb(255, 0, 0);">Width</span><span style="color: rgb(0, 0, 255);">="80"</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">ColumnDefinition</span><span style="color: rgb(0, 0, 255);">></span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">ColumnDefinition</span> <span style="color: rgb(255, 0, 0);">Width</span><span style="color: rgb(0, 0, 255);">="*"</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">ColumnDefinition</span><span style="color: rgb(0, 0, 255);">></span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">ColumnDefinition</span> <span style="color: rgb(255, 0, 0);">Width</span><span style="color: rgb(0, 0, 255);">="80"</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">ColumnDefinition</span><span style="color: rgb(0, 0, 255);">></span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"> <span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">Grid.ColumnDefinitions</span><span style="color: rgb(0, 0, 255);">></span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Grid.RowDefinitions</span><span style="color: rgb(0, 0, 255);">></span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">RowDefinition</span> <span style="color: rgb(255, 0, 0);">Height</span><span style="color: rgb(0, 0, 255);">="*"</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">RowDefinition</span><span style="color: rgb(0, 0, 255);">></span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"> <span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">Grid.RowDefinitions</span><span style="color: rgb(0, 0, 255);">></span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Button</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">="Left"</span> <span style="color: rgb(255, 0, 0);">Content</span><span style="color: rgb(0, 0, 255);">="Left Button"</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">="0"</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">="0"</span> <span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">Button</span><span style="color: rgb(0, 0, 255);">></span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Button</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">="Middle"</span> <span style="color: rgb(255, 0, 0);">Content</span><span style="color: rgb(0, 0, 255);">="Middle Button"</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">="0"</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">="1"</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">Button</span><span style="color: rgb(0, 0, 255);">></span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Button</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">="Right"</span> <span style="color: rgb(255, 0, 0);">Content</span><span style="color: rgb(0, 0, 255);">="Right Button"</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">="0"</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">="2"</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">Button</span><span style="color: rgb(0, 0, 255);">></span></pre> <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"> <span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">Grid</span><span style="color: rgb(0, 0, 255);">></span></pre> </div> <p>The Grid control allows a column to take all the space available. You can do that by setting it's width to "*" and the same goes for the row and its height. The button also have no restrictions for its width and height by the Grid control so it takes all of the available place in the cell.</p> <p><img height="301" width="400" alt="" src="http://www.silverlightshow.net/storage/userfiles/grid.png" /></p> <p>Hope that helps you! ;)</p> http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx#comment411 Enrai http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx Thu, 18 Sep 2008 07:34:56 GMT RE: Using the StackPanel control in Silverlight 2 Beta 1 <p>Look at your first example with Orientation="Horizontal" and notice how the boxes are tall and skinny.  Please show an additional example with three buttons where the middle button fills the space and the first/last buttons have a fixed width.</p> http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx#comment405 Terrence K. http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx Wed, 17 Sep 2008 17:29:34 GMT RE: Using the StackPanel control in Silverlight 2 Beta 1 <p>A simple cute article on the basics of stackpanel, expecting the next article from you.</p> <p> </p> http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx#comment162 Arun Vijai http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx Mon, 09 Jun 2008 23:23:50 GMT RE: Using the StackPanel control in Silverlight 2 Beta 1 <p>Thank u  so much . now i am under stand the stack panel Use. it is help ful to me.</p> http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx#comment152 Raju http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx Wed, 04 Jun 2008 22:01:42 GMT RE: Using the StackPanel control in Silverlight 2 Beta 1 Thank you! It's helpful for me http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx#comment133 Minh http://www.silverlightshow.net/items/Using-the-StackPanel-control-in-Silverlight-2-Beta-1.aspx Fri, 16 May 2008 09:58:39 GMT