views:

44

answers:

1

I'm trying to create a user control that is a combobox that, when opened, presents a treeview of heirarchal data.

I created the user control and replaced a portion of the template in Popup with:

    <ScrollViewer x:Name="ScrollViewer" BorderThickness="0" Padding="1">
         <sdk:TreeView x:Name="Tree">
         </sdk:TreeView>
     </ScrollViewer>

However, I'm not sure how to enable binding on this. The treeview needs to be bound to a different datacontext than the combobox. I tried implementing a DependencyProperty on the user control that would allow me to set the datacontext, but I'm definitely not going about it the right way. At this point, all I get is an empty treeview.

Any help on this would be greatly appreciated.

P.S. One additional caveat is that I need to template the treeview like so:

 <sdk:TreeView x:Name="Tree">
   <sdk:TreeView.ItemTemplate>
     <sdk:HierarchicalDataTemplate ItemsSource="{Binding ChildUnits}">
       <StackPanel Orientation="Vertical" Width="200">
          <TextBlock x:Name="name" TextWrapping="Wrap" Text="{Binding Name}" FontWeight="Bold" />
          <TextBlock x:Name="type" Text="{Binding Id}" FontStyle="Italic" FontSize="10" Foreground="Gray" />
       </StackPanel>
     </sdk:HierarchicalDataTemplate>
  </sdk:TreeView.ItemTemplate>
</sdk:TreeView>
A: 

Anyone have some help on this?

Rodd