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 enough data there for it to give me a row or two.
Those examples are great, should help me out once I get something actually in the datagrid! Took a while for the penny to drop. cheers, Stephen On Tue, Mar 9, 2010 at 12:22 PM, Miguel Madero <[email protected]> wrote: > 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<ToggleButton>(true); > > This will return an IEnumerable of all the ToggleButtons in the DataGrid. > This might include the ones used for sorting in the Header. TO exclude them, > hou could get to the DataGridRowsPresenter (you should only have one) and > then find all the Toggles there. > > dataGrid.GetChild<DataGridRowsPresenter>(true).GetChildren<ToggleButton>(); > > I'm not sure if I wrote a generic GetChild, but you could use > > > dataGrid.GetChildren<DataGridRowsPresenter>(true).First().GetChildren<ToggleButton>(); > > > If you don't use this helpers (or somethign similar), finding things in the > tree is a mess and error prone with controls like the Datagrid that heavily > use templates. > > > -- > Miguel A. Madero Reyes > www.miguelmadero.com (blog) > [email protected] > > _______________________________________________ > ozsilverlight mailing list > [email protected] > http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight > >
_______________________________________________ ozsilverlight mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
