I have a hierarchy that looks like this - Factory>machines>components>controls where ">" can be read as "contains a list of".
This fits very nicely into a TreeView using HierarchicalDataTemplates. Now say I want to add checkboxes to the tree, so that the user can create "views" of the tree that require controlling. Currently my templates are data bound to the actual machine/component/control objects, like so...
<HierarchicalDataTemplate DataType="{x:Type src:Component}" ItemsSource = "{Binding Path=Controls}">
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="False" />
<TextBlock Text="{Binding Path=Name}"/>
</StackPanel>
</HierarchicalDataTemplate>
I dont want to change the code of my machine/component/control classes, to be able to handle "view" creation. In other words, I want to keep the "data model" code and the UI code seperate. For example to handle the checkbox, I need to bind it to a IsSelected property of the Control. I found myself adding a bunch of properties and notification code to the these classes. The other alternative I tried was creating a "view" class for each machine/component/control class. With this approach I ended up creating copies of the data within the "view" classes and having to sync it up with the actual data. Whats a good way to do this?