DataTemplate in Generic.xaml – it should be the next ToString()!
Developers often find some benefit by implementing an override for ToString(). I believe that we could make providing a DataTemplate in generic.xaml very beneficial as well. First we have to start a beneficial cycle…
What could be done with it:
- Apps that use that object in their UI, would have a default data template.
- Tools that help build UI could have a better default data template.
- Visualizers of generic object graphs (like debuggers) could have a better visual representation.
- more…
How to create a default DataTemplate for your type:
- Start with a WPF or Silverlight Control Library project
- Create the class in that project
- Modify themes\generic.xaml to contain a DataTemplate with DataType=”{x:Type l:MyType}”
- (Silverlight doesn’t yet support this…so perhaps you could give your DataTemplate a key of “defaultViewForMyType”)
Thoughts?
Would love to hear what you think…