Silverlight Controls and Silverlight Toolkithttp://forums.silverlight.net//35.aspx/1?Silverlight+Controls+and+Silverlight+ToolkitDiscussions around using and developing Silverlight controls and the Silverlight ToolkitMon, 01 Jan 0001 00:00:00 -050035118106http://forums.silverlight.net//p/42372/118106.aspx/1?Change+the+style+of+cell+within+datagridChange the style of cell within datagrid <p>Hi, as mentioned in the title, is anyone know how to access and obtain the properties of any single cell within the datagrid and change its style base on certain conditions, says if the content value is greater than zero?</p> <p>I am very new to Silverlight, is there any documentation for me to know all the members of datagrid control?</p> <p>&nbsp;</p> <p>Thanks in advance! <br> </p> 2008-10-27T08:03:15-04:00118151http://forums.silverlight.net//p/42372/118151.aspx/1?Re+Change+the+style+of+cell+within+datagridRe: Change the style of cell within datagrid <p>Here is a starting point on the datagrid cell:</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridcell(VS.95).aspx">http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridcell(VS.95).aspx</a></p> <p>Notice the different templates that tie back to the Visual State Manger.&nbsp; Also look at this link:</p> <p><a href="http://msdn.microsoft.com/en-us/library/cc278066(VS.95).aspx">http://msdn.microsoft.com/en-us/library/cc278066(VS.95).aspx</a>&nbsp;for datagrid styles and templates.</p> <p>&nbsp;</p> <p><em>(Please mark as Answered if this helps!)</em>&nbsp;&nbsp; [H]</p> 2008-10-27T09:56:26-04:00118172http://forums.silverlight.net//p/42372/118172.aspx/1?Re+Change+the+style+of+cell+within+datagridRe: Change the style of cell within datagrid <p>&nbsp;Thanks for reply, WadeFlextronics, do you have any sample code to change the properties of datagrid cell?</p> <p>for example, change the foreground color of a datagrid cell which is located on column 2 and row 2 to blue color?</p> <p><br> </p> 2008-10-27T10:26:40-04:00119933http://forums.silverlight.net//p/42372/119933.aspx/1?Re+Change+the+style+of+cell+within+datagridRe: Change the style of cell within datagrid <p>Hi,</p> <p>You can try to refer the below code the&nbsp; change the datagrid's column 2 and row 2's font color&nbsp;to blue.</p> <p>&nbsp;private void peopleDataGrid_LoadingRow(object sender, DataGridRowEventArgs e)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (e.Row.GetIndex() == 2)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.peopleDataGrid.SelectedIndex = e.Row.GetIndex();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataGridColumn column = this.peopleDataGrid.Columns[1];<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FrameworkElement fe = column.GetCellContent(e.Row);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FrameworkElement result = GetParent(fe, typeof(DataGridCell));<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (result != null)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataGridCell cell = (DataGridCell)result;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cell.Foreground = new SolidColorBrush(Colors.Blue);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private FrameworkElement GetParent(FrameworkElement child, Type targetType)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object parent = child.Parent;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (parent != null)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (parent.GetType() == targetType)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (FrameworkElement)parent;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return GetParent((FrameworkElement)parent, targetType);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> 2008-10-29T05:15:54-04:00119988http://forums.silverlight.net//p/42372/119988.aspx/1?Re+Change+the+style+of+cell+within+datagridRe: Change the style of cell within datagrid <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Amanda Wang - MSFT</h4> <p></p> <p>....</p> <p>&nbsp;private void peopleDataGrid_LoadingRow(object sender, DataGridRowEventArgs e)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (e.Row.GetIndex() == 2)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.peopleDataGrid.SelectedIndex = e.Row.GetIndex();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataGridColumn column = this.peopleDataGrid.Columns[1];<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FrameworkElement fe = column.GetCellContent(e.Row);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FrameworkElement result = GetParent(fe, typeof(DataGridCell));<br> </p> <p>.... <br> </p> <p></p> </blockquote> &nbsp; <p></p> <p>Thanks for your help, Amanda! Basically, can you recommend me in learning datagrid? i had been working so much but found it very much different compare to gridview in ASP.NET ...</p> <p>As for this case, the key of code is &quot;e.Row&quot;, is it possible to obtain the row of datagrid like &quot;peopleDataGrid.Row&quot;? because i usually will not going to raise an event to obtain the &quot;e.Row&quot;.</p> <p>&nbsp;</p> 2008-10-29T07:22:58-04:00120114http://forums.silverlight.net//p/42372/120114.aspx/1?Re+Change+the+style+of+cell+within+datagridRe: Change the style of cell within datagrid <p>Hi,</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>siomi</h4> Basically, can you recommend me in learning datagrid? i had been working so much but found it very much different compare to gridview in ASP.NET ...</blockquote> <p></p> <p>Unfortunately, there is no much resource on learning&nbsp;the datagrid. I learn it just from the SDK and the internet. You can try to search on this forum, there are many excellent threads on the DataGrid control, which can be helpful.&nbsp;</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>siomi</h4> As for this case, the key of code is &quot;e.Row&quot;, is it possible to obtain the row of datagrid like &quot;peopleDataGrid.Row&quot;? because i usually will not going to raise an event to obtain the &quot;e.Row&quot;.</blockquote> <p></p> <p>In fact, there are many differences between the ASP.NET DataGrid Control and the SilverLight Control. The Silverlight DataGrid does not have the Rows property.</p> <p>&nbsp;If you want to retrieval the data of a row, you can try to refer the below code:</p> <p>DataGridColumn column= peopleDataGrid.Columns[0];</p> <p>FrameworkElement fe= peopleDataGrid.GetCellContent(people[1]);//people is a collection to which Datagrid is bound </p> <p>The above code will get you the Content of 1st column of 2nd row.</p> <p>&nbsp;</p> 2008-10-29T10:55:49-04:00120141http://forums.silverlight.net//p/42372/120141.aspx/1?Re+Change+the+style+of+cell+within+datagridRe: Change the style of cell within datagrid <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Amanda Wang - MSFT</h4> <p>Hi,</p> <p>You can try to refer the below code the&nbsp; change the datagrid's column 2 and row 2's font color&nbsp;to blue.</p> <p>&nbsp;private void peopleDataGrid_LoadingRow(object sender, DataGridRowEventArgs e)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (e.Row.GetIndex() == 2)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.peopleDataGrid.SelectedIndex = e.Row.GetIndex();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataGridColumn column = this.peopleDataGrid.Columns[1];<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FrameworkElement fe = column.GetCellContent(e.Row);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FrameworkElement result = GetParent(fe, typeof(DataGridCell));<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (result != null)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataGridCell cell = (DataGridCell)result;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cell.Foreground = new SolidColorBrush(Colors.Blue);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private FrameworkElement GetParent(FrameworkElement child, Type targetType)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object parent = child.Parent;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (parent != null)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (parent.GetType() == targetType)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (FrameworkElement)parent;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return GetParent((FrameworkElement)parent, targetType);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p></p> </blockquote> <p></p> <p>&nbsp;</p> <p>very nice [:)] it helped me too. thanks <strong>Amanda Wang</strong></p> 2008-10-29T11:31:08-04:00141677http://forums.silverlight.net//p/42372/141677.aspx/1?Re+Change+the+style+of+cell+within+datagridRe: Change the style of cell within datagrid <p>&nbsp; Hello <strong>Amanda Wang!</strong></p> <p>&nbsp; I have read your code and I have used it.It is very good!<br> </p> <p>&nbsp; But,with your code,I can only change the Foreground of a Cell and I can't change the Background of a Cell.</p> <p>&nbsp; So,can you show me the way which I can use to change the Background of a Cell ?</p> <p>&nbsp; I wrote :&nbsp; cell.Background = new SolidColorBrush(Colors.Red);</p> <p>&nbsp; The code line runs but the Background isn't changed ! </p> <p>&nbsp;Thank you very much !</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SilverlightOIS <br> </p> 2008-12-03T15:12:32-05:00156485http://forums.silverlight.net//p/42372/156485.aspx/1?Re+Re+Change+the+style+of+cell+within+datagridRe: Re: Change the style of cell within datagrid <p>When the data&nbsp; in cell is changed, I need change Foreground again, How can I do this?</p> <p>Ask question again in&nbsp; <a href="http://silverlight.net/forums/p/63281/156483.aspx"> http://silverlight.net/forums/p/63281/156483.aspx</a></p> <p>&nbsp;</p> 2009-01-06T07:23:13-05:00173510http://forums.silverlight.net//p/42372/173510.aspx/1?Re+Re+Change+the+style+of+cell+within+datagridRe: Re: Change the style of cell within datagrid <p>&nbsp;Hello,</p> <p>I am in a similar situation, whereby I need to style a datagrid cell based on it's contents, either altering the foreground/background based on the value of a 'Decimal' field, setting the justification for date fields and making the date display as a short date and setting colour and justification on text fields.</p> <p>The datagrid is bound to a data table and is dynamically created from various SQL calls (being a 'common' datagrid).<br> </p> <p>The contents of e.row are a datarow.rowview and contain the row details as expected.<br> </p> <p>The problem is, with the above code,&nbsp; the following line always returns a null, as does any attempt to get the cellcontent<br> </p> <p>FrameworkElement fe = column.GetCellContent(e.Row); </p> <p>&nbsp;If I apply&nbsp; a 'restyle' via a function from a button click, it works once, but then crashes if I try to perform the restyle again. It also loses the styling if the datagrid is sortged by clicking on the columnheader and any attempt to re-apply the style fails. Another stange action is, once the grid has been dynamically created, if I then call the function to apply the style, the grid is dislayed *without* the modified style. The button on my form calls the exact same function and does nothing else, but this *does* apply the style. It almost seems to me that though the grid is built, because it has not been displayed, the style isn't &quot;known&quot;. <br> </p> <p>&nbsp;If there is a way code wise, or somehow via a style on the datagridcell which could react to the column datatype to call an approriate converter, I'd be very grateful for some pointers as countless hours searching the web has not revealed any answers.<br> </p> <p>I am presuming this is actually do-able of course as unfortunately most of the example I find relating to converters and styling assume the datagrid has the columns hard-set in the XAML.&nbsp; Given that a grid where the explicit column is affected by a converter retains it's styling when the grid is resorted on different columns, I am hoping it is possible.<br> </p> <p>&nbsp;</p> 2009-02-12T13:22:30-05:00185995http://forums.silverlight.net//p/42372/185995.aspx/1?Re+Re+Change+the+style+of+cell+within+datagridRe: Re: Change the style of cell within datagrid <p>I am having the same problem with column.GetCellContent(e.Row). It always returns null. So why do people keep saying that it works? It doesn't work. And I spent most my day searching online for the solution to this problem. Very annoying...</p> <p>I am trying to replace values in the row as it is loaded. For example, if a value&nbsp;equals &quot;-100&quot;, I want it to display as blank.&nbsp;</p> <p>&nbsp;</p> 2009-03-10T20:04:10-04:00186299http://forums.silverlight.net//p/42372/186299.aspx/1?Re+Re+Change+the+style+of+cell+within+datagridRe: Re: Change the style of cell within datagrid <p>&nbsp;John,</p> <p>I gave up in the end, I went this route instead...</p> <p>http://wpf.codeplex.com/Thread/View.aspx?ThreadId=49605</p> <p>Hope that helps you too. <br> </p> 2009-03-11T09:52:58-04:00230260http://forums.silverlight.net//p/42372/230260.aspx/1?Re+Re+Change+the+style+of+cell+within+datagridRe: Re: Change the style of cell within datagrid <p><a href="http://www.mystudyworld.com/?p=60">&nbsp;Try This it might help...</a></p> <p>&nbsp;</p> <p>Thanks,</p> <p>puneet <br> </p> 2009-06-07T14:02:44-04:00231421http://forums.silverlight.net//p/42372/231421.aspx/1?Re+Change+the+style+of+cell+within+datagridRe: Change the style of cell within datagrid <p>Hi, Amanda</p> <p>&nbsp;</p> <p>Thanks for snippet, it worked for me... I was also trying the same thing and it worked</p> <p><br> </p> <p>Bhagirath Patadia <br> </p> 2009-06-10T10:16:48-04:00250336http://forums.silverlight.net//p/42372/250336.aspx/1?Re+Change+the+style+of+cell+within+datagridRe: Change the style of cell within datagrid Hi Amanda , Thanx but i got that ereror when my task is complete succefully so what is the problem &quot;Object reference not set to an instance of an object&quot;. Thanx in Advance 2009-07-15T13:25:59-04:00294625http://forums.silverlight.net//p/42372/294625.aspx/1?Re+Re+Change+the+style+of+cell+within+datagridRe: Re: Change the style of cell within datagrid Hi can i check the cell value in this event...??<br> <br> <font size="2"><font size="2"></font></font><font size="2"><font size="2"></font><font color="#0000ff" size="2">private</font><font size="2"> </font><font color="#0000ff" size="2">void</font><font size="2"> Grid1stQuad_LoadingRow(</font><font color="#0000ff" size="2">object</font><font size="2"> sender, </font><font color="#2b91af" size="2">DataGridRowEventArgs</font><font size="2"> e)</font></font><font size="2"> <p>{</p> <p>&nbsp;</p> </font> <p><font color="#2b91af" size="2">FrameworkElement</font><font size="2"> fe = col.GetCellContent(e.Row);</p> </font><font size="2"> <p></font><font color="#2b91af" size="2">FrameworkElement</font><font size="2"> result = GetParent(fe, </font><font color="#0000ff" size="2">typeof</font><font size="2">(</font><font color="#2b91af" size="2">DataGridCell</font><font size="2">));</font></p> <p><font size="2">}</p> </font> 2009-09-30T07:11:32-04:00294648http://forums.silverlight.net//p/42372/294648.aspx/1?Re+Re+Change+the+style+of+cell+within+datagridRe: Re: Change the style of cell within datagrid <p>you can try this</p> <p><span style="font-size:10pt; font-family:Arial"><span style="">&nbsp;</span><span style="">&nbsp;</span>Private Sub Alert_RowLoaded(ByVal sender As Object, ByVal e As DataGridRowEventArgs)</span><br> <span style="font-size:10pt; font-family:Arial"><span style="">&nbsp; &nbsp; &nbsp; &nbsp; </span>Dim objCOl As ObservableCollection(Of BindableObject)</span><br> <span style="font-size:10pt; font-family:Arial"><span style="">&nbsp; &nbsp; &nbsp; &nbsp; </span>objCOl = CType(CType(sender, DataGrid).ItemsSource, ObservableCollection(Of BindableObject))</span><br> <span style="font-size:10pt; font-family:Arial"><span style="">&nbsp; &nbsp; &nbsp; &nbsp; </span>Dim dr As DataRow</span><br> </p> <p class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-size:10pt; font-family:Arial"><span style="">&nbsp; &nbsp; &nbsp; &nbsp; </span>dr = objCOl(e.Row.GetIndex).DataRow</span></p> <p>&nbsp; &nbsp; &nbsp; &nbsp; 'dr(0) is your cell value<br> <br> <span style="font-size:10pt; font-family:Arial"><span style="">&nbsp; &nbsp; &nbsp; &nbsp; </span>If dr(0).ToString.Contains(&quot;Pending&quot;) Then</span><br> <span style="font-size:10pt; font-family:Arial"><span style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span> e.Row.Background = New SolidColorBrush(Colors.Red)</span><br> <span style="font-size:10pt; font-family:Arial"><span style="">&nbsp; &nbsp; &nbsp; &nbsp; </span>End If</span><br> <span style="font-size:10pt; font-family:Arial"><span style="">&nbsp; &nbsp; </span>End Sub</span></p> 2009-09-30T07:55:52-04:00595120http://forums.silverlight.net//p/42372/595120.aspx/1?Re+Change+the+style+of+cell+within+datagridRe: Change the style of cell within datagrid Hi All, FrameworkElement result = GetParent(fe, typeof(DataGridCell)); Who can tell me the GetParent(,) method of the above code which come from where in silverlight. Thanks, -Andy Chen&#65279; 2011-09-23T11:30:43-04:00