wpf - Exposing a sub-control in a UserControl for use in XAML -


I have a UserControl that has a TreeView, I want the user to set the properties of internal TreeView control through XAML And I'm not sure how to do this.

I have tried to make TreeView a public property on UserControl, but it only allows me to set the chosen ITemChanged trigger.

I have to do something like this:

  & lt; ExampleUserControl & gt; & Lt; ExampleUserControl.TreeView.ItemTemplate & gt; ... & lt; / Example user control. Tree View.ItemTemplate & gt; & Lt; / ExampleUserControl>  

or:

  & lt; Example User Controller TreeView.ItemsSource = "{Binding Foo}" />  

I do not want to create properties in UserControl for each TreeView property, and I do not want to force the user to define control in C #.

To pass many control properties in your user control, you always expose a styled property You can.

i.e. hair style

Unless you use [Josh Smith's Element Spier / Data Context / Freezeball] [1] move, you disconnected on datacontaxes Will go

So you either employ those tips or just have 2 properties.

1) ITSOURCE 2) Child style

xaml ends ...

  & lt; ChildTreeAnswer: MyControl ItemsSource = "{Binding Items}" & gt; & Lt; ChildTreeAnswer: MyControl.ChildStyle & gt; & Lt; Style & gt; & Lt; Setter property = "itemscontrol.itmatelet" & gt; & Lt; Setter.Value & gt; & Lt; DataTemplate & gt; & Lt; Border borderbrush = "black" borderline = "1" margin = "5" & gt; & Lt; Text block text = "{binding}" /> & Lt; / Border & gt; & Lt; / DataTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt; & Lt; / ChildTreeAnswer: MyControl.ChildStyle & gt; & Lt; / ChildTreeAnswer: myControl>  

Then under its user control ... (I have used a listback for simplicity sake)

    

Comments