Using DataContext

Jan 26, 2013 at 8:14 PM
Edited Jan 26, 2013 at 8:16 PM

I see in your samples you always set the DataContext to the root node, But i want to use my existing DataContext. I have a "Nodes" property in my DataContext object that i want to use.

How would i achieve this?

How is it practical having to set the DataContext to the root node to use the control?

 

Edit:

I set my DataContext in the xaml code, and have no code-behind in the xaml.cs file.

<Window.DataContext>
        <ll:ViewModel />
</Window.DataContext>

Is this still possible using your control?

Coordinator
Jan 27, 2013 at 10:50 AM

Hi

You can use the complete WPF flexibility. Just bind to whatever collection in your ViewMode you want:

HierarchicalItemsSource="{Binding <PropertyWithYourCollection>}"