Apr 11th, 2011, 02:33 PM
[RESOLVED] Template v UserControl
Hi - Still new to WPF and trying to get my head round the proper way of doing things.
I want to create a listbox which displays a reasonably complex structure for each item. What I envisage is something like two rows of text (which themselves may be made up from the values of several properties) and one or more buttons, including one to "delete" the item itself.
I have been able to set up the listbox to do most of that using DataTemplate and Style manipulation, except for implementing the buttons which I'm struggling to see how I would work it this way.
Would I better off defining a usercontrol which includes the structure I want and all the buttons, but then how do I get my listbox to use it? At the moment my ViewModel for the list contains a collection of another ViewModel type which represents the item - should I have the list ViewModel contain a collection of my usercontrol instead? That doesn't feel right.
I'm probably just going round in circles over something thats fairly obvious but at the moment I cant see the wood for the trees.
Apr 11th, 2011, 02:47 PM
Re: Template v UserControl
'SOkay - I figured it out.
A combination of the two approaches does the trick - using a DataTemplate to reference the user control.
Click Here to Expand Forum to Full Width