views:

117

answers:

1

I would like to define two similar-looking views on some graphical data. One view is an editor and the other is a viewer that shows the data being transformed. I am not sure what the best way is to share code and resources between the two views, but I have tentatively decided to make a UserControl to represent the part of the visual presentation that is common between the two.

It makes the most sense to store Styles and ControlTemplates as resources of the UserControl, but how, in XAML, can I use a style defined in the UserControl within one of the views (where the UserControl is a child of the view)?

A: 

If you're using the type as the template key, there isn't a way to have both at once. However, if you're willing to add some sort of keying/enumeration mechanism for the different types of graphical views.

Also, is the graphical data abstracted as an object tree, and if so, wouldn't switching DataTemplates make more sense?

micahtan
"if you're willing to add some sort of keying/enumeration mechanism for the different types of graphical views." then what?It may make sense to use DataTemplates to display my data. But what container should I put the objects in so that each object has independent coordinates (I'm currently using a 1x1 Grid and I used to use a Canvas, but those containers can't hold arbitrary objects, right?)
Qwertie
I am now trying to use DataTemplates to represent my items in a ItemsControl with a custom ControlTemplate that contains a Grid in a ScrollViewer. Now I'm having trouble handling events in a DataTemplate - http://stackoverflow.com/questions/870137/wpf-how-to-attach-mouse-events-to-a-viewmodel
Qwertie