none
Binding content to a property of type UIElement

    General discussion

  • I have the following interfaces:

    public interface IPropertyPage {

     string Title { get; }

     UIElement UI { get; }

    }

     

    public interface IPropertyPages:ICollection<IPropertyPage> {

    }

     

    and I want to make a templated custom control, which would have a property of type IPropertyPages and show the control returned by UI property of each property pages from the IPropertyPages collection and set the tab header using the Title property.

    I could do this in code, but would prefer to be able to do it in XAML so that a user of the control could override the template and use say Accordion instead of a TabControl, where sections would host the control returned by the UI property of each property page and section titles would use the Title property of the PropertyPage (or a Tree control to show all those property editing custom UIs in one pane as collapsible/expandable sections [not showing only one at a time as in accordion]). [note: The design of those property pages is supposed to use two-way data binding to talk to the control providing the property pages collection (IPropertyPagesProviders), so not using OK/Apply/Cancel etc.]

    what I don't understand is how I can bind to the UI property which is a UIElement and place it as content in the XAML, should I use some dummy container control and set its content via binding to the value of the UI property? (that is have ItemsSource of say TabControl bind to the PropertyPages collection and have some ItemTemplate/Header or similar with a container in it like Border the content property of which will bind to the UI property of each item?)

    thanks in advance for any insights and sample code

    Friday, April 27, 2012 6:39 PM

All replies