• behance
  • gitHub
  • google
  • linkedin
  • twitter
WPF UserControl == DataTemplate

WPF UserControl == DataTemplate

Over the weekend I was doing a fair amount of UI stuff on a major project of mine and stumbled across a very cool and neat solution to using data templates.  One of the great strengths of WPF is its ability to ‘componentise’ things into nice bite sized chunks of functionality/UI.  Anyone using WPF or learning WPF will soon find the need for DataTemplates in order to style and control the display of any data created by an application.  Until now I had been using ‘Inline’ DataTemplates held in the Resources section of a Window or a Page which is nice and still a very valid way of doing things, but this solution in this demo is seriously neat.  Define a UserControl and use that as your DataTemplate.  Keeps your XAML nice and clear and makes it really easy to design the look and feel of a DataTemplate in Expression Blend.

Anyway, that’s enough wibbling.  Grab the demo solution at the link below and have a looksee.

WPF User Control As DataTemplate Demo Solution (VS2008)

You can also view a more indepth explanation of this (with a more complete demo solution included) in my article covering this technique on Code Project.

Share

Leave a reply

*