Re: Button in a datagrid cell

2010-03-09 Thread Miguel Madero
:) On Tue, Mar 9, 2010 at 11:43 PM, Stephen Price wrote: > I got it working in the end, and it did seem to be an absence of data > causing the prob which makes sense. no data, no rows. :) > > I then had to figure out how to invoke the click event of a togglebutton. I > endedup Toggling the toggle

Re: Button in a datagrid cell

2010-03-09 Thread Miguel Madero
I imagine you're showing the Datagrid in the Panel for the UnitTest. Keep in mind that it uses a VirtualizingStackPanel, so if there's no visible area, I would expect that no rows will be created (althoug I would at least expect to have a DataGridRowsPresenter) so I'm not sure if that could be the

Re: Button in a datagrid cell

2010-03-09 Thread Stephen Price
I got it working in the end, and it did seem to be an absence of data causing the prob which makes sense. no data, no rows. :) I then had to figure out how to invoke the click event of a togglebutton. I endedup Toggling the togglebutton and changed the event from click event to Checked/Unchecked.

Re: Button in a datagrid cell

2010-03-08 Thread Stephen Price
Strange, Not getting a DataGridRowsPresenter or any children from the datagrid in the unit test. I think I need to look at what data is in it, and somehow mock it (so it's still a unit test and not an integration test). The viewmodel data object its binding to is pretty complicated. I just want eno

Re: Button in a datagrid cell

2010-03-08 Thread Miguel Madero
With the class that I send you you can use the Extension method GetChildren (for UIElements), use the recursive overload to find a ToggleButton, it should look something like datagrid.GetChildren(true); This will return an IEnumerable of all the ToggleButtons in the DataGrid. This might include t

Re: Button in a datagrid cell

2010-03-08 Thread Miguel Madero
Something useful is to do Linq Queries. from b in element.GetChildren where b.Name == 'someName' && b.Tag = myExpectedValue select b You could even restrict it a bit, to discard other buttons in other places (like toggle buttons in the header). from r in dg.GetChildren() from c in r.GetChildren

Re: Button in a datagrid cell

2010-03-08 Thread Miguel Madero
Check in SilverlightSpy. Use Cotrol+Shift+Mouse Over to find it and look at the Visualtree, then use one of the GetChildren overloads in this class to find it public static class VisualTreeExtensions { public static IEnumerable GetChildren(this DependencyObject depObject) { int count = depObj