I've got a list of custom "pages" in my app. Each page represents a different UI view. They have some simple properties, like a string title and an icon, but they also have a number of complex properties, consisting of controls to insert into the main toolbar, a main content area, custom statusbar panels, etc. The page type derives from FrameworkElement
so that data binding works properly inside of each page's XAML. So far, everything I've described works great.
The problem comes when I try to quickly throw up a list of all pages. I've got an ItemsControl
which I've bound to the list of active pages, and a DataTemplate
assigned to an ItemTemplate
consisting of just a label bound to the page's Title
property (as noted, it's just a plain string). When I run it, however, nothing displays in the list and I get this in the error output:
System.Windows.Data Error: 25 : ItemTemplate and ItemTemplateSelector are not valid for item.; Type='WelcomePage'
If I change the base type to anything but FrameworkElement
the template works but data binding within each page breaks down horribly (binding to items via ElementName
fails, despite both of the involved controls being children of a common FrameworkElement
, which is defined within the page's XAML).
Anyone know of a way to either get a DataTemplate to apply to a FrameworkElement-derived type or to get data binding to work in a XAML file rooted by a non-FrameworkElement?