I have a list of custom βpagesβ in my application. Each page represents a different user interface. They have some simple properties, such as a title bar and icon, but they also have a number of complex properties consisting of controls for pasting into the main toolbar, the main content area, custom status bar panels, etc. The page type comes from the FrameworkElement so that the data binding works correctly inside each XAML page. So far, everything that I described works fine.
The problem occurs when I try to quickly list all the pages. I have an ItemsControl that I have linked to a list of active pages, and a DataTemplate assigned an ItemTemplate consisting only of a label attached to the property of the Title page (as noted, this is just a simple string). However, when I run it, nothing is displayed in the list, and I get this in the error output:
System.Windows.Data error: 25: ItemTemplate and ItemTemplateSelector are not valid for the item; Type = 'WelcomePage'
If I change the base type to anything other than FrameworkElement , the template works, but the data binding to each page breaks terribly (the binding to the elements through the ElementName fails, despite the fact that both the involved controls are children of the general FrameworkElement , which defined on the XAML page).
Does anyone know a way to get a DataTemplate to apply to a FrameworkElement based type, or get data binding to work in a XAML file embedded by a non-FrameworkElement?
source share