tags:

views:

31

answers:

1

I'm looking for a way to control which Tab of a TabView is shown based on which item of a TreeView is selected. Does anyone know of a way to do this?

+1  A: 

If the TabControl and the TreeView is bound to the same date source (ItemsSource), you should be able to set the IsSynchronizedWithCurrentItem on the TabControl to keep the 2 in sync... I think you might also have to use the TreeViewEx project, since the TreeView inside WPF does some funny things sometimes... but first give it a go...

<TreeView 
    ItemsSource="{Binding something}" />
<TabControl 
    ItemsSource="{Binding something}"
    IsSynchronizedWithCurrentItem="True" />
rudigrobler
What is TreeViewEx?
Brian Ortiz
Also, it doesn't work. Perhaps because TreeView is not a Selector?
Brian Ortiz
Search for TreeViewEx, I think it derives from selctor (Not sure) it is also part of the sharpDevelop project!
rudigrobler
This is a hack but you can also create a behavior that attaches a event handler when a item is selected and then fires a action (Normal behaviors in blend) and then create a action that can set the tab! Althou this uses event handlers, it then makes it totally xaml-able?
rudigrobler