SilverlightShow: DataGrid and row details 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: DataGrid and row details in Silverlight <p>hello, </p> <p>I have a datagridview that is created in code-behind. would you have an equivalent to show row details in code-behind?</p> <p>thanks in advance</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment6596 siobhan http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Mon, 03 Oct 2011 11:41:48 GMT RE: DataGrid and row details in Silverlight <p>I have Row Details with an Image button to Collapsed selected RowDetails. I tried different options </p> <p>for example, i tried Search for parent row of a Rowdetails and collaps RowDetails to perticular Row.</p> <p>any help will be appriciated.</p> <p>Thanks</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment6136 SBJ http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Fri, 13 May 2011 20:51:17 GMT RE: DataGrid and row details in Silverlight <ul> <li>fasfasf </li> </ul> <ol> <li><strong><em>fadsfasf</em></strong></li> </ol> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment5983 fs http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Tue, 26 Apr 2011 18:51:46 GMT RE: DataGrid and row details in Silverlight <em>The article has been updated to the latest version of Silverlight and Visual Studio.</em> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment5146 lnikolov http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Wed, 22 Dec 2010 18:21:19 GMT RE: DataGrid and row details in Silverlight 2 <p>I was having the same issue when I remove the HeadersVisisbility in the details datagrid. If you remove the following </p> <p><span style="font-family: consolas;"><span style="color: #ff0000; font-size: 13px;">HeadersVisibility</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="None"</span></span></p> <p>You should be able to see details</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment4527 Felix http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Wed, 22 Sep 2010 23:27:57 GMT RE: DataGrid and row details in Silverlight 2 <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;"></span> </p> <p>Hi, </p> <p>I am trying to create a Row Detail in DataGrid in Silverlight 4.I have a DataSource as</p> <p>Public User parentUser{get;set;}  </p> <p>Public List<User> childUsers{get;set;}</p> <p> </p> <p>In the First Grid I have to display all the parentUser details and In the detaisl Grid I ahev to display all the childusers associated with the parentUser. </p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;"></span> </p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;"><</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">sdk</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">:</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">DataGrid</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> AutoGenerateColumns</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="False"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> HorizontalAlignment</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="Left"</span><span style="font-family: consolas; font-size: 13px;"> </span><span style="font-family: consolas; color: #ff0000; font-size: 13px;">Name</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="UserViewModelDataGrid"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> RowDetailsVisibilityMode</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="VisibleWhenSelected"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> VerticalAlignment</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="Top"></span><span style="font-family: consolas; color: #a31515; font-size: 13px;">   <p> </p> </span></p> <p> </p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;">   <</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">sdk</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">:</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">DataGrid.Columns</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">></span><span style="font-family: consolas; color: #a31515; font-size: 13px;"> </span></p> <p>       <span style="font-family: consolas; color: #0000ff; font-size: 13px;"><</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">sdk</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">:</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">DataGridTextColumn</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> Header</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="Description"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> Binding</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="{</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">Binding</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> Description</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">}"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> SortMemberPath</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="ActvityValue"/></span><span style="font-family: consolas; color: #a31515; font-size: 13px;"> </span></p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;">    <</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">sdk</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">:</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">DataGridTextColumn</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> Header</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="First Name"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> Binding</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="{</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">Binding </span><span style="font-family: consolas; color: #ff0000; font-size: 13px;">FirstName</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">}"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> SortMemberPath</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="FirstName"/></span></p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;">    <</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">sdk</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">:</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">DataGridTextColumn</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> Header</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="LastName"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> Binding</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="{</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">Binding</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> LastName</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">}"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> SortMemberPath</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="LastName"/></span></p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;">   <</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">/</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">sdk:</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;"><span style="font-family: consolas; color: #0000ff; font-size: 13px;"><span style="font-family: consolas; color: #0000ff; font-size: 13px;"><span style="font-family: consolas; color: #a31515; font-size: 13px;">DataGrid.Columns</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">></span><span style="font-family: consolas; color: #a31515; font-size: 13px;"> </span> <p> </p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;"><</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">sdk</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">:</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">DataGrid.RowDetailsTemplate</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">></span></p> </span> <p> </p> </span> <p> </p> </span></p> <p> </p> <p><span style="color: #444444; font-size: 13px;"> </span></p> <p><span style="font-size: 13px;"><span style="font-family: consolas; color: #0000ff;"><</span><span style="font-family: consolas; color: #a31515;">DataTemplate</span><span style="font-family: consolas; color: #0000ff;">></span></span></p> <p><span style="font-family: consolas; color: #a31515; font-size: 13px;"><span style="font-family: consolas; color: #a31515; font-size: 13px;"><span style="font-family: consolas; color: #a31515; font-size: 13px;"> <p> </p> <p> </p> </span> <p> </p> </span> <p> </p> </span></p> <p> </p> <p> </p> <p> </p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;"><</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">sdk</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">:</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">DataGrid</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> HeadersVisibility</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="None"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> AutoGenerateColumns</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="False"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> DetailsVisibilityMode</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="VisibleWhenSelected"</span><span style="font-family: consolas; color: #000000; font-size: 13px;"> </span><span style="font-family: consolas; color: #ff0000; font-size: 13px;">HorizontalAlignment</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="Left"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> Name</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="childUsersViewModelDataGrid"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> ItemsSource</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="ChildUsers"> </span></p> <p> <<span style="font-family: consolas; color: #a31515; font-size: 13px;">DataGrid.Columns</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">></span> </p> <p> </p> <p><span style="font-family: consolas; font-size: 13px;"><span style="color: #0000ff;"><</span><span style="color: #a31515;">sdk</span><span style="color: #0000ff;">:</span><span style="color: #a31515;">DataGridTextColumn</span><span style="color: #ff0000;"> Header</span><span style="color: #0000ff;">="First Name"</span><span style="color: #ff0000;"> Binding</span><span style="color: #0000ff;">="{</span><span style="color: #a31515;">Binding ChildUsers.</span><span style="color: #ff0000;">FirstName</span><span style="color: #0000ff;">}"</span><span style="color: #ff0000;"> SortMemberPath</span><span style="color: #0000ff;">="FirstName"/></span></span></p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;">    <</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">sdk</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">:</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">DataGridTextColumn</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> Header</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="LastName"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> Binding</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="{</span><span style="font-family: consolas; color: #a31515; font-size: 13px;">Binding</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> ChildUsers.LastName</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">}"</span><span style="font-family: consolas; color: #ff0000; font-size: 13px;"> SortMemberPath</span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">="LastName"/></span></p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;"></DataGrid.Columns></span></p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;">....</span></p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;"></span> </p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;">By the above way I am only able to display the parent rows and non of the details show up..</span></p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;">i AM NOT ABLE TO UNDERSTAND WHERE i AM DOING WRONG. </span></p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;">i REQUEST SOME SOLUTIONS AND SUGGESTIONS PLEASE.</span></p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;">Thanks in Advance.</span></p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;"></span> </p> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;"></span> </p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment4230 BMR http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Thu, 12 Aug 2010 17:12:05 GMT RE: DataGrid and row details in Silverlight 2 <p>Thank you!</p> <p>This was exactly what I was looking for. Now it's a piece of cake to create your own gridtree, since you can have a datagrid inside your DataTemplate. Add a extrector and hide the headr if you want and you are done.</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment3673 Thomas http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Thu, 27 May 2010 15:15:18 GMT RE: DataGrid and row details in Silverlight 2 Heloo to all ! <div><br /> </div> <div>i m strucj wid datagrid's row template ,</div> <div>actualy i want access the textbox placed in my row-template .</div> <div><br /> </div> <div>plz any 1 4 help , do reply !</div> <div><br /> </div> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment3376 Param http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Tue, 13 Apr 2010 10:40:33 GMT RE: DataGrid and row details in Silverlight 2 <p>Hi,</p> <p>Article is really great. Can we have separate  row details for every column. Like in above case one detail for Group, another for Name and so on. Please reply me at guptarahulrk@gmail.com</p> <p>-Rahul Gupta</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment3290 Rahul Gupta http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Tue, 23 Mar 2010 10:58:59 GMT RE: DataGrid and row details in Silverlight 2 <p>Hi,</p> <p>Article is really great. Can we have separate  row details for every column. Like in above case one detail for Group, another for Name and so on. Please reply me at guptarahulrk@gmail.com</p> <p>-Rahul Gupta</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment3289 Rahul Gupta http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Tue, 23 Mar 2010 09:27:29 GMT RE: DataGrid and row details in Silverlight 2 <p>Hi,</p> <p>I have a DataGrid with various columns and RowDetails with TextBox. When I surf with the tab key, the TextBox RowDetails does not receive focus after exiting the last column in the DataGrid. What should I do to the TextBox receives focus on column navigation sequence?</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment2953 Pedro Palma http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Fri, 22 Jan 2010 16:09:10 GMT RE: DataGrid and row details in Silverlight 2 using button? <p> </p> <br /> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment2253 huhu http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Tue, 18 Aug 2009 08:13:26 GMT RE: DataGrid and row details in Silverlight 2 Hello, how could i raise event DataGridRowDetailsEventArgs just when i click in one single cell and not in all row, i have more than one detail <p>tks</p> <p>Rafael</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment1625 Rafael http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Sat, 30 May 2009 18:45:58 GMT RE: DataGrid and row details in Silverlight 2 Hello everyone... I have the same issue, a datagrid in another datagrid and i don't know how to reference it... Or how to bind some list of object to it... Pls help (also new in silvelight) http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment1398 Tibi http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Wed, 01 Apr 2009 07:55:49 GMT RE: DataGrid and row details in Silverlight 2 I have a datagrid in the DataTemplate of a RowsDetailTemplate.  How do I reference it?<br /> <span style="font-size: 13px"> <p><span style="font-size: 13px; color: #0000ff"><span style="font-size: 13px; color: #0000ff">  <p> </p> <p> </p> </span> <p> </p> </span></p> <p><span style="font-size: 13px; color: #a31515"></span> </p> </span> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment1184 alphalima http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Mon, 16 Mar 2009 16:23:09 GMT RE: DataGrid and row details in Silverlight 2 <p>i want to display another datagrid by selecting the row of a another datagrid.........plz help me....am new in silverlight</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment1018 rose http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Thu, 05 Feb 2009 23:28:54 GMT RE: DataGrid and row details in Silverlight 2 <p>Well done!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment822 JUANID http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Fri, 12 Dec 2008 12:21:29 GMT RE: DataGrid and row details in Silverlight 2 <p>First off, thanks for article!</p> <p>I would like to use a datagrid to show multi table data that has an 1 to many relationship. There's no problem showing the parent row with DataBinding. I've put a DataGrid in my DataTemplate just fine. Using the RowDetailsVisibilityChanged event I can set the binding for the Detail DataGrid.</p> <p>The problem I am experienceing is that the SelectedIndex seems to be a step behind what's happening.</p> <p>For example, the first time it fires (on load of the parent grid) the value is -1. When I click on the fourth row, SelectedIndex is 0, and then if I click back to the first row, the SelectedIndex is 3. I'm guessing that the event is fired before the Index value is changed.</p> <p>Another issue I am facing is that I would like to make the loading of the details grid conditional on a value in the parent row. Since the SelectedIndex seems to be a step behind, I tried to use the SelectionChanged event to get at the data. But that seems to be fired after the RowDetailsVisibilityChanged is.</p> <p>I think I could code around these issues, but it doesn't seem to make sense that I would need to. Am I missing something here?</p> <p>Thanks!</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment798 mHectorGato http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Thu, 04 Dec 2008 12:56:04 GMT RE: DataGrid and row details in Silverlight 2 <p>You can try to change the cell template by setting the CellStyle property for the cell taht you have taken as selected. Here is the <a href="http://www.silverlightshow.net/storage/userfiles/generic.xaml">generic.xaml for the DataGrid</a>. In it find the style for the DataGridCell and configure the ControlTemplate to your likings. Then place the configured template in the style for the selected cell. ;)</p> <p> </p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment794 Enrai http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Thu, 04 Dec 2008 03:15:09 GMT RE: DataGrid and row details in Silverlight 2 <p>Uhm!  Hello All!</p> <p>I am working with Datagrid of Silverlight  and I have a proplem with it . So I hope everyone who know it can help me!</p> <p>My proplem is : I have a Datagrid,when the data is loaded,I want to change the Background and the Foreground of a cell.</p> <p>I can't  take a cell in the grid , I have search in Google and now I can take a cell, but I can only change the Foreground of a cell  and I can't change the Background of a cell.</p> <p>I used the code in the follow link : <a href="http://silverlight.net/forums/t/42372.aspx">http://silverlight.net/forums/t/42372.aspx</a> .  THANK YOU VERY MUCH !</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment788 SilverlightOIS http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Wed, 03 Dec 2008 10:09:39 GMT RE: DataGrid and row details in Silverlight 2 <p>1) When having an active control such as Button, RadioButton, CheckBox etc. in a DataGrid you can't use them (at least for now) to manipulate the row they are placed in. The reason is that the focus goes to the control but its row doesn't get focused. So the <em><strong>SelectionChanged </strong></em>event doesn't fire, the <em><strong>SelectionIndex</strong></em> doesn't get changed and you have no information about the row that the control is placed in.</p> <p>2) There is no way to get the RowDetail for particular row and manipulate it, as there is no collection for the rows of the DataGrid.</p> <p>Why don't you just set the <em><strong>RowDetailsVisibilityMode</strong></em> to <em>VisibleWhenSelected</em>? It makes the details visible when the row is selected and I think the result is identical with what you want to achieve. You use the checkbox to select the row and then expand the its Rowdetails - as I understand it, if you use the <em>VisisbleWhenSelected</em> you spare yourself a lot of code and an additional column and the result is the same.</p> <p>Sorry if I missunderstood you, if you ment something else, please explain it and I'll try to help you. :)</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment744 Enrai http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Mon, 24 Nov 2008 03:58:47 GMT RE: DataGrid and row details in Silverlight 2 <p>Hello,<br /> <br /> I have a question, how should I know that "What Row holds the specified Control with the Specified data?"</p> <p>My xaml code is:</p> <p> </p> <p><br />         <my:DataGrid x:Name="dg1" <br />                                  RowDetailsVisibilityMode="Collapsed" <br />                                  AutoGenerateColumns="False" <br />                                  Margin="0,0,0,90" <br />                                  Style="{StaticResource DataGridStyle1}"<br />                                  SelectionChanged="dg1_SelectionChanged" <br />                                  SelectionMode="Single"<br />                                  ><br />             <my:DataGrid.RowDetailsTemplate><br />                 <DataTemplate><br />                     <StackPanel Orientation="Horizontal" Background="White"><br />                         <!-- In the row details you can also use binding as in the column definitions, <br />                         because it shares the same DataContext as the row. --><br />                         <TextBlock Margin="5,5,5,5" Width="350" Text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum varius. Nullam felis purus, lacinia at, molestie non, porttitor sit amet, lectus. Fusce molestie, diam ac rutrum faucibus, nulla diam luctus. " TextWrapping="Wrap"/><br />                     </StackPanel><br />                 </DataTemplate><br />             </my:DataGrid.RowDetailsTemplate><br />             <my:DataGrid.Columns ><br />                 <my:DataGridTemplateColumn Header="Expand" ><br />                     <my:DataGridTemplateColumn.CellTemplate><br />                         <DataTemplate  ><br />                             <StackPanel Orientation="Horizontal"><br />                                 <CheckBox x:Name="grdChkBox1" Height="17.334" <br />                                                 HorizontalAlignment="Left" <br />                                                 Style="{StaticResource CheckBoxStyle1}" <br />                                                 VerticalAlignment="Bottom" <br />                                                 Width="95.333" d:LayoutOverrides="Height" Click="grdChkBox1_Click"/><br />                             </StackPanel><br />                         </DataTemplate><br />                     </my:DataGridTemplateColumn.CellTemplate><br />                 </my:DataGridTemplateColumn><br />                 <my:DataGridTextColumn Binding="{Binding Path=FirstName}" Header="First Name" IsReadOnly="True"/><br />                 <my:DataGridTextColumn Binding="{Binding Path=LastName}" Header="Last Name"/><br />                 <my:DataGridTextColumn Binding="{Binding Path=LastName}" Header="Age"/><br />                 <br />             </my:DataGrid.Columns><br />         </my:DataGrid><br />  </p> <p> </p> <p>My xaml.cs code is :</p> <p>    List<Data> source = new List<Data>();<br />             int itemsCount = 100;<br /> <br />             for (int i = 0; i < itemsCount; i++)<br />             {<br />                 source.Add(new Data()<br />                 {<br />                     FirstName = i+"First",<br />                     LastName = i + "Last",<br />                     Age = i,<br />                     Available = (i % 2 == 0)<br />                 });<br />             }<br /> <br />             dg1.ItemsSource = source;</p> <p> </p> <p>Now what I want is , when somebody clicked on my the "Chekbox" then I want 1) To see which "Row"  is need to be expanded, 2) Give me the "Row" detail so I can enable the "RowDetailsVisibilityMode="Collapsed"  to visible.</p> <p> </p> <p>Any idea how I can acheive this via Event Handler?<br /> <br /> Thanks,<br /> <br /> Mudassir Azeemi</p> <p> </p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment740 Mohammed Mudassir Azeemi http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Fri, 21 Nov 2008 15:37:33 GMT RE: DataGrid and row details in Silverlight 2 <p><strong>@VK</strong> I have also tried the same, it's the most logical approach, but as you said - no effect. At first look it seems that the problem is in the SelectedIndex property, but I investigated a bit the issue and found that when the ItemsSource is set and the data is bound the SelectedIndex is set to 0. Sadly there i no event that fires when the data is bound. If you do something like this:</p> <div><div style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt; border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%;"> <pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt; border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em; background-color: white;">Foods.ItemsSource = data;</pre><pre style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt; border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em;">Foods.SelectedIndex = -1;</pre></div></div> <p>it won't work. It seems that when the SelectedIndex is set the data is still not bound and after that it gets set again.</p> <p>Me and one of my collegues have found some kind of workaround for this issue.</p> <p>When the SelectedIndex is set to 0 the SelectionChanged event is raised and we use it in order to set the SelectedIndex, knowing that it won't be changed behind the scenes anymore.</p> <div> <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">public</span> Page()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">{</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"> </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"> InitializeComponent();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"> ...</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"> Foods.ItemsSource = data;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"> <span style="color: #0000ff">this</span>.Foods.SelectionChanged += SetDefaultSelectedIndex;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">}</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"> </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">void</span> SetDefaultSelectedIndex( <span style="color: #0000ff">object</span> sender, SelectionChangedEventArgs e )</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">{</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"> <span style="color: #0000ff">this</span>.Foods.SelectionChanged -= SetDefaultSelectedIndex;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"> <span style="color: #0000ff">this</span>.Foods.SelectedIndex = -1;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">}</pre></div></div> <p>The problem here is that the SelectionChanged is an important event for the DataGrid and we may want to use it with another purpose later on. This issue occurs only when the data is bound, so when we handle this SelectionChanged event with the intention to set the SelectedIndex to -1, we also dettach the handler from it. Here you can also attach the handler that we'll be used further on.</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment721 Enrai http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Wed, 19 Nov 2008 09:29:28 GMT RE: DataGrid and row details in Silverlight 2 <p>When I choose constant height it works fine, but setting height to Auto doesnt work. Thanks for your help</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment718 Rajmund http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Wed, 19 Nov 2008 02:47:24 GMT RE: DataGrid and row details in Silverlight 2 <p>By default the first row is always selected and the Row details are visible (I have <font color="#ff0000" size="2">RowDetailsVisibilityMode </font><font color="#0000ff" size="2">= "VisibleWhenSelected"</font><font size="2"> ). I tried datagrid.SelectedIndex = - 1 and datagrid.SelectedItem = null. Doesn't seem to manke any difference.</font></p> <p><font size="2">I would like to have the RowDetails collapsed by defaul and visible when selected. Any thoughts on this.</font></p> <p><font size="2">Thanks</font></p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment715 VK http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Tue, 18 Nov 2008 20:10:23 GMT RE: DataGrid and row details in Silverlight 2 <p><em><strong>@Rajmund</strong></em> The height of the row details template depends on the height of the controls in it. In my example I can control the width and the height of the row details via the width and the height of the <em><strong>StackPanel </strong></em>control. So try setting the hegith of the layout control to <em>Auto </em>or choose a constant height that will suit all row details.</p> <p><em><strong>@Fernando Z</strong></em> I assume that you're trying to do the following thing: You want your control to be disabled, but when the cell is selected you want it to be active. I also have tried to do that, but I haven't found a way to access the selected cell and work with the controls in it. I have also tried the following: I have defined them as disabled in the XAML, but when disabled they doesn't get focus, so there is no event I could hook up in order to enable them again. I'm going to try the trick with the transparency, that you have shown in your code.</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment710 Enrai http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Tue, 18 Nov 2008 10:48:21 GMT RE: DataGrid and row details in Silverlight 2 <p>I have little problem with details row template.</p> <p>Is it possible to change height of the details row?</p> <p>Sometimes i can't see all information in details row</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment706 Rajmund http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Tue, 18 Nov 2008 09:57:53 GMT RE: DataGrid and row details in Silverlight 2 <p>My Sincere apologies about the above post.  I didn't realize it would post the way it did.</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment674 Fernando Z http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Thu, 13 Nov 2008 14:58:05 GMT RE: DataGrid and row details in Silverlight 2 <p>Why use the DataGridTemplateColumsn allow you to define your columns however you want.  As show below I  have a grid with a textbox in one column and a customized checkbox in the other. </p> <p>Fernando</p> <p>[code]</p> <div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"> <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);">my:DataGrid.Columns</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, 128, 0);"><!-- Could not figure out how to enable/disable controls within Data Template so </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, 128, 0);">I just hooked events to them and disabled them in the event handlers --></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);">my:DataGridTemplateColumn</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">="columnDescription"</span> <span style="color: rgb(255, 0, 0);">CanUserSort</span><span style="color: rgb(0, 0, 255);">="True"</span> <span style="color: rgb(255, 0, 0);">SortMemberPath</span><span style="color: rgb(0, 0, 255);">="Description"</span> <span style="color: rgb(255, 0, 0);">Width</span><span style="color: rgb(0, 0, 255);">="360"</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(255, 0, 0);">Header</span><span style="color: rgb(0, 0, 255);">="Description"</span> <span style="color: rgb(255, 0, 0);">IsReadOnly</span><span style="color: rgb(0, 0, 255);">="False"</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);">my:DataGridTemplateColumn.CellTemplate</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);">DataTemplate</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);">Border</span> <span style="color: rgb(255, 0, 0);">CornerRadius</span><span style="color: rgb(0, 0, 255);">="4"</span> <span style="color: rgb(255, 0, 0);">BorderThickness</span><span style="color: rgb(0, 0, 255);">="5,5,5,5"</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);">StackPanel</span> <span style="color: rgb(255, 0, 0);">Orientation</span><span style="color: rgb(0, 0, 255);">="Horizontal"</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);">TextBox</span> <span style="color: rgb(255, 0, 0);">MaxLength</span><span style="color: rgb(0, 0, 255);">="100"</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">="txtDescriptionInList"</span> <span style="color: rgb(255, 0, 0);">LayoutUpdated</span><span style="color: rgb(0, 0, 255);">="txtDescriptionInList_LayoutUpdated"</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(255, 0, 0);">Width</span><span style="color: rgb(0, 0, 255);">="350"</span> <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">="Center"</span> <span style="color: rgb(255, 0, 0);">BorderThickness</span><span style="color: rgb(0, 0, 255);">="0"</span> <span style="color: rgb(255, 0, 0);">Text</span><span style="color: rgb(0, 0, 255);">="{Binding Description, Mode=TwoWay}"</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(255, 0, 0);">GotFocus</span><span style="color: rgb(0, 0, 255);">="txtDescriptionInList_GotFocus"</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, 128, 0);"><!--Make the textbox transparent--></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);">TextBox.Background</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);">SolidColorBrush</span> <span style="color: rgb(255, 0, 0);">Color</span><span style="color: rgb(0, 0, 255);">="White"</span> <span style="color: rgb(255, 0, 0);">Opacity</span><span style="color: rgb(0, 0, 255);">="0"</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);">TextBox.Background</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);">TextBox</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);">StackPanel</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);">Border</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);">DataTemplate</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);">my:DataGridTemplateColumn.CellTemplate</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);">my:DataGridTemplateColumn</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);">my:DataGridTemplateColumn</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">="columnAvailable"</span> <span style="color: rgb(255, 0, 0);">CanUserSort</span><span style="color: rgb(0, 0, 255);">="True"</span> <span style="color: rgb(255, 0, 0);">Width</span><span style="color: rgb(0, 0, 255);">="140"</span> <span style="color: rgb(255, 0, 0);">Header</span><span style="color: rgb(0, 0, 255);">="Availability"</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(255, 0, 0);">SortMemberPath</span><span style="color: rgb(0, 0, 255);">="Available"</span> <span style="color: rgb(255, 0, 0);">IsReadOnly</span><span style="color: rgb(0, 0, 255);">="False"</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);">my:DataGridTemplateColumn.CellTemplate</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);">DataTemplate</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);">Border</span> <span style="color: rgb(255, 0, 0);">CornerRadius</span><span style="color: rgb(0, 0, 255);">="4"</span> <span style="color: rgb(255, 0, 0);">BorderThickness</span><span style="color: rgb(0, 0, 255);">="5,5,5,5"</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);">StackPanel</span> <span style="color: rgb(255, 0, 0);">Orientation</span><span style="color: rgb(0, 0, 255);">="Horizontal"</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, 128, 0);"><!--<Image Margin="20,0,20,0" Width="20" Height="20" Canvas.Left="0" Canvas.Top="0" </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, 128, 0);"> Source="{Binding AvailableImage, Mode=TwoWay}" Stretch="Fill"/>--></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, 128, 0);"><!--<CheckBox Margin="10,0,0,0" VerticalAlignment="Center" </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, 128, 0);"> IsChecked="{Binding Available, Mode=TwoWay}"></CheckBox>--></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);">CheckBox</span> <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">="Stretch"</span> <span style="color: rgb(255, 0, 0);">IsChecked</span><span style="color: rgb(0, 0, 255);">="{Binding Available, Mode=TwoWay}"</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(255, 0, 0);">Style</span><span style="color: rgb(0, 0, 255);">="{StaticResource CheckBoxAvailableAsset}"</span> <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">="Stretch"</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(255, 0, 0);">RenderTransformOrigin</span><span style="color: rgb(0, 0, 255);">="0.5,0.5"</span> <span style="color: rgb(255, 0, 0);">IsThreeState</span><span style="color: rgb(0, 0, 255);">="False"</span> <span style="color: rgb(255, 0, 0);">Content</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(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">="Transparent"</span> <span style="color: rgb(255, 0, 0);">Click</span><span style="color: rgb(0, 0, 255);">="CheckBox_Click"</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);">CheckBox.RenderTransform</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);">TransformGroup</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);">ScaleTransform</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);">SkewTransform</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);">RotateTransform</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);">TranslateTransform</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);">TransformGroup</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);">CheckBox.RenderTransform</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);">CheckBox</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);">StackPanel</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);">Border</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);">DataTemplate</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);">my:DataGridTemplateColumn.CellTemplate</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);">my:DataGridTemplateColumn</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);">my:DataGrid.Columns</span><span style="color: rgb(0, 0, 255);">></span></pre> </div> </div> <p>[/code]</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment673 Fernando Z http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Thu, 13 Nov 2008 14:52:50 GMT RE: DataGrid and row details in Silverlight 2 <p>If you take a closer look at your sample you'll notice that clicking on the TextBox doesn't change the row selection, but if you click somewhere outside the TextBox in the cell the selection is changed. The same happens if you use another active control like button, radio button etc, so I guess that's the reason. I think it got something to do with the focus, but for now I don't have a concrete explanation. You can consider trying to use to use a TextBlock control and put the TextBox into the EditingTemplate of the cell, if this suits your application.</p> <p>If you come with any other ideas, share them please! :)</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment597 Enrai http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Thu, 30 Oct 2008 02:57:08 GMT RE: DataGrid and row details in Silverlight 2 <p>Thanks for your reply</p> <p>Now, i use the DataTemplate(TextBox) to implement my project.</p> <p>And, I find that when i change the row, the SelectionChanged event can't be fired.</p> <p>I use the common datagrid and DataTemplate(TextBlock), both of them are Ok.</p> <p>Why datagrid's SelectionChanged event can't be fired using DataTemplate(TextBox)?</p> <p>Thanks</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment596 AK http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Wed, 29 Oct 2008 23:09:23 GMT RE: DataGrid and row details in Silverlight 2 <p>You can find the index of the currently selected row in the <em><strong>SelectedIndex</strong></em> property of the DataGrid. Just note the indexing of the rows starts from 0.</p> <p>If you have more questions, don't hesitate to ask! ;)</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment595 Enrai http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Wed, 29 Oct 2008 07:57:19 GMT RE: DataGrid and row details in Silverlight 2 <p>Hi, Enrai</p> <p>I want to ask you another question about datagrid,</p> <p>When i select the row which i want, how to get the number of row?</p> <p>eg. I select the row 3, so in the source how can i get the "3" using selectchanged event?</p> <p>Thanks..</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment594 AK http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Tue, 28 Oct 2008 20:55:16 GMT RE: DataGrid and row details in Silverlight 2 <p><strong>@Necriis:</strong> Which event do you mean - the RowDetailsVisibilityChanged one? Or one of the events I used in the previous article about the Editing in the DataGrid? Sorry if I missunderstood you :)</p> <p><strong>@Frank:</strong> First the DataGrid has a collection only for the columns and second you can't access a specific cell using the DataGrid column. So do only thing I think of is to use the <em><strong>SelectedItem</strong></em> property of the DataGrid as it contains the DataContext for the entire row. From the DataContext you can easily gather the desired data. If I come into a better way to do this, I'll let you know.</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment584 Enrai http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Fri, 24 Oct 2008 04:30:39 GMT RE: DataGrid and row details in Silverlight 2 <p> </p> <div style="margin: 0in 0in 0pt"><span style="color: #1f497d">The datagrid in my example is two dimensional</span></div> <div style="margin: 0in 0in 0pt"> </div> <div style="margin: 0in 0in 0pt"><span style="color: #1f497d">Six columns across</span></div> <div style="margin: 0in 0in 0pt"><span style="color: #1f497d">10 rows down</span></div> <div style="margin: 0in 0in 0pt"> </div> <div style="margin: 0in 0in 0pt"><span style="color: #1f497d">I want to get the data out of the one cell that intersects Row 6 column 4  (6,4)</span></div> <div style="margin: 0in 0in 0pt"> </div> <p class="MsoNormal" style="margin: 0in 0in 0pt"><o:p></o:p><font face="Calibri" size="3">the name of the datagrid is "theDG"</font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt"> </p> <p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3">the name of the fourth column is colD</font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt"> </p> <p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3">I think the code is something like the following (C#)</font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3">itemC = theDG.rows[6].colD</font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt"> </p> <p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3">any ideas?</font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt"> </p> <p class="MsoNormal" style="margin: 0in 0in 0pt"><font face="Calibri" size="3">Thanks</font></p> <p> </p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment575 Frank http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Tue, 21 Oct 2008 13:40:58 GMT RE: DataGrid and row details in Silverlight 2 <p>Great article !</p> <p>Is this the only (easiest) way to catch a cell modification event ? (Best I've seen, for now ...)</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment565 Necriis http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Mon, 20 Oct 2008 07:12:41 GMT RE: DataGrid and row details in Silverlight 2 <p>Hi, ak!</p> <p>I have added a link to the source code, it seems I had forgotten about it, thanks for reminding me! :)</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment523 Enrai http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Thu, 09 Oct 2008 00:13:06 GMT RE: DataGrid and row details in Silverlight 2 <p>Could you upload your soure please?</p> http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx#comment521 ak http://www.silverlightshow.net/items/DataGrid-and-row-details-in-Silverlight-2.aspx Wed, 08 Oct 2008 18:47:10 GMT