WPF DataGrid default column types

Hi,

I'm using a DataGrid to display 2 possible types of DataRow in a DataTable. One type has the column Parent = NULL and the other has Parent set to another DataRow in the same DataTable. The list of column in the DataTable is always different, so explicitly describing each column is not possible.

I want to display a UserControl in every cell of the Parent = DataRow rows, and default Text / Check boxes for the Parent = NULL rows. My first strategy is to try and set the default Column type for all automatically generated columns to be a DataGridTemplateColumn, regardless of datatype, so that I can use styles to then use either my UserControl or CheckBox or TextBox where required. How can I do this?

More importantly, though, is there a better strategy than this?

Cheers, Dave
AJS_DeveloperAsked:
Who is Participating?
 
AJS_DeveloperAuthor Commented:
Thanks for your suggestion mikebirt. I've now abandoned the DataGrid in favour of a ListView which I've found meets my needs a littler better.
0
 
mikebirtCommented:
Hi,

this is kind of a 30,000ft overview so i'm not sure i understand your situation exactly, but is it possible to use data templates rather than user controls and use the type binding to resolve which UI to use? so you create a data temlpate for the data type displayed?

Otherwise i wonder if you'd be able to set the cell control template within a style where you can apply a trigger to the Parent property? i think this allow you to have your two cell templates...

i could be barking up the wrong tree(s) here, these were just my thoughts...

HTH

Mike
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.