I'm building a Wpf app that currently has a toolbox which looks and functions similarly to the Visual Studio toolbox. I have a range of classes that are represented in the toolbox and different types of objects that can each contain some, but not all, of the toolbox items.
As a stopgap measure to get my app up and going, I hardcoded the toolbox functionality into the UserControls. Now I must progress to a better design that isn't hardcoded.
I've got a simple ToolBoxItem class that has properties for Type, Label and Icon. Each class that needs to go into the toolbox is added to a collection of ToolBoxItems and is displaying correctly.
But I am struggling to come up with an elegant solution for two problems:
My feeling is that delegates and perhaps generics could be a solution but I've only consumed those features in the past and am unsure how to proceed.
A good example of what you're trying to achieve can be found in AvalonDock, which is completely open source. If you want to see how to use AvalonDock with MVVM (i.e. putting tools in windows and so on), check out the SoapBox Core Framework.