WPF: Master / Detail Situation
I have an area on the left with selectable items, and depending on which type of item is selected, I want to show one of three or four different shapes on the right.
It would be nice to do some type of control, so the main form might be useless.
What's the best template for this in WPF?
I'm new to WPF and I've spent some time in some obviously wrong directions. Thanks!
a source to share
I would say, whenever possible, Templates are the way to go in WPF. They determine how controls or data are displayed in the user interface. Using templates, you can use any object (not just strings), for example, the content of a button. If you set a type object for the button's content MyType
, WPF will look for the DataTemplate for MyType
in resources and use it if found. If the DataTemplate is not found, it will use ToString()
this object's method and display the result.
In your script, you can use the simple one ContentControl
to view your information on the right and define a different one DataTemplate
for each type of item. If not every element needs a different template (i.e. some types use the same template), you can implement ContentTemplateSelector
to define the correct one DataTemplate
programmatically.
An overview of data templates provides a good introduction to this topic.
HTH, good luck!
a source to share