tags:

views:

776

answers:

2

If have a WPF datagrid on the left of a Window with an area to the right for displaying the selected record. The selected record consists of Textboxes and ComboBoxes that are disabled until the edit button is clicked. All works as expected.

However, it seems a bit clumsy to be populating ComboBoxes when the SelectedItem of the DataGrid being changed. A much lighter control such as a TextBlock could be used until the Edit button is clicked, then the TextBlocks could be switched out for ComboBoxes.

I'm sure this can be done with some sort of templating but when I tried to experiment with this, all of the events that are associated with the ComboBoxes report an error as they're no longer present as they have been replace with TextBlocks in "View mode".

I'm probably going about this wrong so some guidance would be appreciated.

A: 

The ContentTemplateSelector property should allow you to select one template or another depending on the current mode (view/edit)

Thomas Levesque
+2  A: 

here is excelent article by DR. WPF

ArsenMkrt
Thanks Arsenmkrt, I've seen some of Dr WPF's articles but you're right, this one is along the lines of what I'm looking for.
Mitch