Reputation: 1162
I'm looking to represent a collection of different but related data types and give the user the chance to edit these. I can't represent them in a grid because each type is different and therefore doesn't lend itself to a grid layout.
e.g.
Type1
- properties are From, To, Threshold, Enabled
Type2
- properties are From, ExecutedPercent, Benchmark, Enabled
etc
These types are related but different so I'm thinking of creating a tool bar with the types along the top. When the user selects Type1 I generate the UI using a custom ItemTemplate on a ListBox, same for Type2. I am therefore swapping out the ItemTemplate at runtime and changing the data source.
Questions:
1. Does this sound like a reasonable approach?
2. Does it make sense to item template ListBox?
3. Are there any other controls I should think about templating here? It seems to me that ListBox is about the perfect candidate for any kind of List source when all the items need to be displayed.
Thanks in advance
Upvotes: 1
Views: 77
Reputation: 17274
In order to handle different types of items you can use ItemTemplateSelector which will be more clear WPF solution.
If you do not need having selected item in listbox and only need to display items then you should use ItemsControl
instead of ListBox
Upvotes: 1
Reputation: 2423
you can use a datatemplateselecter so you dont have to set the itemtemplate when the type is switched just change the datasource.
Upvotes: 0