SilverlightShow: Using the Grid 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 Grid control in Silverlight <p>In my layout position, I want a column on left side of my content which should work as margin only. This column should be minimized to width of 0 when browser is minimized and should be maximized to 100 when browser is maximized. I tried with width = "*" MinWidth = "0" and MaxWidth="100" but this is not working as there is no content in the column.<br /> <br /> Please suggest me any idea.<br /> thanks in advance...!!</p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment9666 NareshRavlani http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Thu, 25 Jul 2013 16:47:06 GMT Re: Using the Grid control in Silverlight <p>great resource. explained very well</p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment6371 JunwenGa http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Sun, 24 Jul 2011 15:47:09 GMT RE: Using the Grid control in Silverlight <strong><em>This good article</em></strong> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment5979 Rafik Mondal http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Tue, 26 Apr 2011 14:03:20 GMT RE: Using the Grid control in Silverlight Very nice article for Beginners..Thanks a lot!! http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment5880 Prasanna Padkil http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Mon, 11 Apr 2011 12:18:04 GMT RE: Using the Grid control in Silverlight <p><strong>Thanks a lot</strong>, It was very helpfull for me.</p> <p></p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment5184 bpS Rajput http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Thu, 30 Dec 2010 07:27:07 GMT RE: Using the Grid control in Silverlight <p><em>The article has been updated to the latest version of Silverlight and Visual Studio.</em></p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment5142 lnikolov http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Wed, 22 Dec 2010 17:50:00 GMT RE: Using the Grid control in Silverlight 2 Very helpful... was getting myself in knots over here :) http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment5127 Gavin http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Mon, 20 Dec 2010 14:27:39 GMT RE: Using the Grid control in Silverlight 2 thnx it was very helpfull........ http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment5038 Santosh http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Tue, 07 Dec 2010 12:28:41 GMT RE: Using the Grid control in Silverlight 2 is it possible to reteive a control at a particular row and column ? http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment4430 XYZ http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Fri, 10 Sep 2010 00:53:55 GMT RE: Using the Grid control in Silverlight 2 how to add controls dynamically from codebehind to Grid using MVVM http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment4344 arun http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Fri, 27 Aug 2010 17:58:21 GMT RE: Using the Grid control in Silverlight 2 Thanks http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment3494 Kareem http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Sat, 24 Apr 2010 23:40:14 GMT RE: Using the Grid control in Silverlight 2 Good Artical http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment2284 Charu http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Wed, 26 Aug 2009 09:46:53 GMT RE: Using the Grid control in Silverlight 2 <span style="font-weight: bold; ">Kannan</span>, you can try the following:<div><br /></div><div><span><div style="overflow-x: auto; overflow-y: auto; background-color: white; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(127, 157, 185); border-right-color: rgb(127, 157, 185); border-bottom-color: rgb(127, 157, 185); border-left-color: rgb(127, 157, 185); line-height: 100% !important; font-family: 'courier new'; font-size: 11px; "><table cellpadding="0" cellspacing="0" style="width: 99%; margin-top: 2px; margin-right: 0px; margin-bottom: 2px; margin-left: 0px; border-collapse: collapse; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); background-color: rgb(255, 255, 255); border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "> <col style="font-family: 'courier new'; font-size: 11px; padding-left: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(247, 247, 247); white-space: nowrap; " /> <tbody> <tr> <td><span style="font-size: 11px; ">this.grdLayoutRoot.ColumnDefinitions[1]</span><span style="color: red; ">.Width</span><span style="font-size: 11px; "> = </span><span style="color: blue; ">new</span><span style="font-size: 11px; "> GridLength(200); </span></td> </tr> </tbody></table></div></span><br /></div><div><span style="font-weight: bold; ">Sonal</span>, <span style="font-style: italic; ">SetRow</span> will apply to the <span style="font-style: italic; ">Grid</span> into which the control is. In my examples above you can see that the <span style="font-style: italic; ">Button</span> and the <span style="font-style: italic; ">Rectangle</span> are into the <span style="font-style: italic; ">Grid</span>. <br /></div><div><br /></div><div>For dynamically adding rows you can try the following:</div><div><br /></div><div><span><div style="overflow-x: auto; overflow-y: auto; background-color: white; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(127, 157, 185); border-right-color: rgb(127, 157, 185); border-bottom-color: rgb(127, 157, 185); border-left-color: rgb(127, 157, 185); line-height: 100% !important; font-family: 'courier new'; font-size: 11px; "><table cellpadding="0" cellspacing="0" style="width: 99%; margin-top: 2px; margin-right: 0px; margin-bottom: 2px; margin-left: 0px; border-collapse: collapse; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); background-color: rgb(255, 255, 255); border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "> <col style="font-family: 'courier new'; font-size: 11px; padding-left: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(247, 247, 247); white-space: nowrap; " /> <tbody> <tr> <td><span style="font-size: 11px; ">RowDefinition </span><span style="color: red; ">rd</span><span style="font-size: 11px; "> = </span><span style="color: blue; ">new</span><span style="font-size: 11px; "> RowDefinition(); </span></td> </tr> <tr> <td style="background-color: rgb(247, 247, 247); "><span style="color: red; ">rd.Height</span><span style="font-size: 11px; "> = </span><span style="color: blue; ">new</span><span style="font-size: 11px; "> GridLength(50); </span></td> </tr> <tr> <td>this.grdLayoutRoot.RowDefinitions.Add(rd); </td> </tr> </tbody></table></div></span><br /></div><div>For dynamically adding controls to the <span style="font-style: italic; ">Grid</span> you can try:</div><div><br /></div><div><span><div style="overflow-x: auto; overflow-y: auto; background-color: white; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(127, 157, 185); border-right-color: rgb(127, 157, 185); border-bottom-color: rgb(127, 157, 185); border-left-color: rgb(127, 157, 185); line-height: 100% !important; font-family: 'courier new'; font-size: 11px; "><table cellpadding="0" cellspacing="0" style="width: 99%; margin-top: 2px; margin-right: 0px; margin-bottom: 2px; margin-left: 0px; border-collapse: collapse; border-bottom-style: solid; border-bottom-color: rgb(238, 238, 238); background-color: rgb(255, 255, 255); border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; "> <col style="font-family: 'courier new'; font-size: 11px; padding-left: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(247, 247, 247); white-space: nowrap; " /> <tbody> <tr> <td><span style="font-size: 11px; ">Button </span><span style="color: red; ">btn</span><span style="font-size: 11px; "> = </span><span style="color: blue; ">new</span><span style="font-size: 11px; "> Button(); </span></td> </tr> <tr> <td style="background-color: rgb(247, 247, 247); "><span style="color: red; ">btn.Content</span><span style="font-size: 11px; "> = </span><span style="color: blue; ">"New Control"</span><span style="font-size: 11px; ">; </span></td> </tr> <tr> <td>this.grdLayoutRoot.Children.Add(btn); </td> </tr> <tr> <td style="background-color: rgb(247, 247, 247); ">Grid.SetRow(btn, 1); </td> </tr> <tr> <td>Grid.SetColumn(btn, 1); </td> </tr> </tbody></table></div></span><br /></div><div><span style="font-weight: bold; ">Daniel</span>, may be your solution will work in Silverlight 3. I tried it in Silverlight 2 but it did not work for me.<br /></div> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment1607 nikolayraychev http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Tue, 26 May 2009 07:40:08 GMT RE: Using the Grid control in Silverlight 2 <p>it is possible give an specific position in a row/column to a control using an id, and not the position of the row/column</p> <p>example --> <columndefinition x:uid="column_1" /></p> <p>                    <Textblock grid.column="column_1"/></p> <p>if i want to make a change adding a new row/column will be slow change the position to every control created.</p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment1597 daniel.valenzuela.a http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Mon, 25 May 2009 18:41:26 GMT RE: Using the Grid control in Silverlight 2 <span style="color: #2b91af; font-size: 13px"> <p>Grid</p> </span> <p><span style="font-size: 13px">.SetRow(), if I have two grids in my page then to which grid SetRow() will be applied. I want to add dynamic controls <br /> to a row in grid and also want to add rows dynamically to a grid. Can you please let me know if you have any idea?</span></p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment1367 Sonal http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Tue, 31 Mar 2009 02:49:00 GMT RE: Using the Grid control in Silverlight 2 Thanks for this article.<br /> Is it possible to dynamically vary the width of one column of a Grid. I want the Gird of 4 * 4 structure. In this i want the 2nd column of the 1st row to vary in its width based on user's selection. Is that possible to set it in the code behind ? http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment1279 Kannan http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Wed, 25 Mar 2009 09:43:10 GMT RE: Using the Grid control in Silverlight 2 Set Horizontal- and VerticalAlignment to Left/Top. Default for Grid seems to be stretch.<br /> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment1276 RobeK http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Wed, 25 Mar 2009 06:09:55 GMT RE: Using the Grid control in Silverlight 2 <p>Thanks for the article.</p> <p>Is it possible for the grid to resize to automatically fit just the size of its contents. e.g I have a grid like the following:</p> <p><Grid x:Name="test" Background="White" ShowGridLines="True"><br />             <Grid.RowDefinitions><br />                 <RowDefinition Height="30"></RowDefinition><br />                 <RowDefinition Height="Auto"></RowDefinition><br />                 <RowDefinition Height="30"></RowDefinition>                <br />             </Grid.RowDefinitions><br />             <Grid.ColumnDefinitions><br />                 <ColumnDefinition Width="30"></ColumnDefinition><br />                 <ColumnDefinition Width="Auto"></ColumnDefinition><br />                 <ColumnDefinition Width="30"></ColumnDefinition>                <br />             </Grid.ColumnDefinitions><br />             <TextBox Text="Hello" Grid.Row="1" Grid.Column="1" Background="Transparent" BorderThickness="0"/><br />         </Grid></p> <p>Currently it takes up the full space of its parent canvas. The last column ignores the width specified (30) and stretches to the entire canvas. I want the grid size to be just the size of the textbox + the 30 either side.</p> <p>Thanks</p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment1126 Mark http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Thu, 05 Mar 2009 04:01:20 GMT RE: Using the Grid control in Silverlight 2 <p> Nice Article</p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment1079 Rohan http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Fri, 20 Feb 2009 02:30:27 GMT RE: Using the Grid control in Silverlight 2 <p>Hi <strong>ohaiyo</strong>,</p> <p>I can't find any property of the <em>Grid</em> which defines a grid lines brush.</p> <p>An easy workaround may be to hide the grid lines and to put a <a href="http://www.silverlightshow.net/items/Using-the-Border-control-in-Silverlight-2-Beta-1-.aspx">Border</a> control in each "cell".</p> <p>Nikolay</p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment527 nikolayraychev http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Thu, 09 Oct 2008 06:56:58 GMT RE: Using the Grid control in Silverlight 2 <p>i want to create table with solid border.  how do? thank you!</p> <p>(i want to place custom UserControl in each cell of table)</p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment525 ohaiyo http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Thu, 09 Oct 2008 02:24:42 GMT RE: Using the Grid control in Silverlight 2 <p>How to set dashed of the grid to <font style="font-size: 14px">solid? </font></p> <p> </p> <p><font style="font-size: 14px">gomienie@gmail.com</font></p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment524 ohaiyo http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Thu, 09 Oct 2008 02:12:23 GMT RE: Using the Grid control in Silverlight 2 <p>Thanks for your comment, <strong>Vijaykumar</strong>.</p> <p>There is no object for the <em>Grid</em> cell. But a solution may be to put a <em>Canvas</em> like the example in the previous comment and customize it dynamically. The <em>Canvas</em> will act as a table cell and you can access it from the code behind. You are not limited in putting a <em>Canvas</em>. You can put another <a href="http://www.silverlightshow.net/items/Layout-controls-in-Silverlight-2-Beta-1.aspx">layout control</a>.</p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment277 nikolayraychev http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Mon, 04 Aug 2008 01:12:07 GMT RE: Using the Grid control in Silverlight 2 <p>Is it possible to customize cell wise rather than column wise dynamically?</p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment274 Vijaykumar Channakeshava http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Sun, 03 Aug 2008 21:23:03 GMT RE: Using the Grid control in Silverlight 2 <p>Hi Mariusz,</p> <p>We do not have an object for the <em>Grid</em> cell, but we can easily highlight a cell when the mouse is over by putting a <em>Canvas</em> in it. The following example demonstrates it:</p> <div id="gridCellMouseOverDemo" style="border-right: black 2px solid; border-top: black 2px solid; border-left: black 2px solid; width: 400px; border-bottom: black 2px solid; height: 300px"><object height="100%" width="100%" type="application/x-silverlight-2" data="data:application/x-silverlight-2,"> <param value="http://www.silverlightshow.net/showcase/HighlightGridCellOnMouseOver.xap" name="source" /> <param value="onSilverlightError" name="onerror" /> <param value="white" name="background" /> <param value="2.0.31005.0" name="minRuntimeVersion" /> <param value="true" name="autoUpgrade" /><a style="text-decoration: none" href="http://go.microsoft.com/fwlink/?LinkID=124807"><img style="border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none" alt="Get Microsoft Silverlight" src="http://go.microsoft.com/fwlink/?LinkId=108181" /> </a></object><iframe style="border-right: 0px; border-top: 0px; visibility: hidden; border-left: 0px; width: 0px; border-bottom: 0px; height: 0px"></iframe></div> <p>XAML:</p> <div style="border-right: black 2px solid; padding-right: 10px; border-top: black 2px solid; padding-left: 10px; padding-bottom: 10px; border-left: black 2px solid; padding-top: 10px; border-bottom: black 2px solid"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"><</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">UserControl</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'"> x</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">:</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'">Class</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">="HighlightGridCellOnMouseOver.Page"</span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'">   <span style="color: red"> xmlns</span><span style="color: blue">="http://schemas.microsoft.com/winfx/2006/xaml/presentation"</span> </span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'">   <span style="color: red"> xmlns</span><span style="color: blue">:</span><span style="color: red">x</span><span style="color: blue">="http://schemas.microsoft.com/winfx/2006/xaml"</span> </span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'">   <span style="color: red"> Width</span><span style="color: blue">="400"</span><span style="color: red"> Height</span><span style="color: blue">="300"></span></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">    </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"><</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">Grid</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'"> x</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">:</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'">Name</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">="LayoutRoot"</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'"> ShowGridLines</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">="True"</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'"> Background</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">="White"></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">        </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"><</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">Grid.RowDefinitions</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">            </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"><</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">RowDefinition</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">RowDefinition</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">            </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"><</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">RowDefinition</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">RowDefinition</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">            </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"><</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">RowDefinition</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">RowDefinition</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">        </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"></</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">Grid.RowDefinitions</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">        </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"><</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">Grid.ColumnDefinitions</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">            </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"><</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">ColumnDefinition</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">ColumnDefinition</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">            </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"><</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">ColumnDefinition</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">ColumnDefinition</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">            </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"><</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">ColumnDefinition</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">ColumnDefinition</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">        </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"></</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">Grid.ColumnDefinitions</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">        </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"><</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">Canvas</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'"> MouseEnter</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">="cnvHighlight_MouseEnter"</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'"> MouseLeave</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">="cnvHighlight_MouseLeave"</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'"> Background</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">="White"</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'"> x</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">:</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'">Name</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">="cnvHighlight"</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'"> Grid.Row</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">="1"</span><span style="font-size: 10pt; color: red; font-family: 'Courier New'"> Grid.Column</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">="1"></</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">Canvas</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">    </span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'"></</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">Grid</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></div> <span style="font-size: 10pt; color: blue; font-family: 'Courier New'"></</span><span style="font-size: 10pt; color: #a31515; font-family: 'Courier New'">UserControl</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">></span></span></div> <p>Code behind:</p> <div style="border-right: black 2px solid; padding-right: 10px; border-top: black 2px solid; padding-left: 10px; padding-bottom: 10px; border-left: black 2px solid; padding-top: 10px; border-bottom: black 2px solid"> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">private</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">void</span> cnvHighlight_MouseEnter( <span style="color: blue">object</span> sender, <span style="color: #2b91af">MouseEventArgs</span> e )</span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'">{</span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'">     <span style="color: #2b91af">SolidColorBrush</span> yellowBrush = <span style="color: blue">new</span> <span style="color: #2b91af">SolidColorBrush</span>( <span style="color: #2b91af">Colors</span>.Yellow );</span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'">     <span style="color: blue">this</span>.cnvHighlight.Background = yellowBrush;</span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'">}</span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">private</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">void</span> cnvHighlight_MouseLeave( <span style="color: blue">object</span> sender, <span style="color: #2b91af">MouseEventArgs</span> e )</span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'">{</span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'">     <span style="color: #2b91af">SolidColorBrush</span> whiteBrush = <span style="color: blue">new</span> <span style="color: #2b91af">SolidColorBrush</span>( <span style="color: #2b91af">Colors</span>.White );</span></div> <div style="margin: 0in 0in 0pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'">     <span style="color: blue">this</span>.cnvHighlight.Background = whiteBrush;</span></div> <span style="font-size: 10pt; font-family: 'Courier New'">}</span></div> <p>We just attach to the <em>MouseEnter</em> and <em>MouseLeave</em> events of the Canvas and change the <em>Background</em> <em>Brush</em>. By default the <em>Canvas</em> takes the whole available space in the cell.</p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment93 nikolayraychev http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Thu, 10 Apr 2008 06:15:00 GMT RE: Using the Grid control in Silverlight 2 <p>Is it possible to highlight one cell of the grid, when the mouse pointer gets over it?</p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment88 Mariusz http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Thu, 10 Apr 2008 01:04:26 GMT RE: Using the Grid control in Silverlight 2 <p>Hi, I like your tutorials about the layout possibilities in silverlight.</p> http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx#comment87 Mariusz http://www.silverlightshow.net/items/Using-the-Grid-control-in-Silverlight-2-Beta-1.aspx Thu, 10 Apr 2008 01:03:10 GMT