views:

1099

answers:

2

What I'd like is a control that functions just like the tab control but instead of having the tabs along the top, the items would be displayed in a list box along the side. I imagine it's possible but haven't found any examples, I'm hoping there's someone here that's done something like this.

+10  A: 

WPF controls are designed to enable exactly what you want. To reuse control functionality while completely replacing the visual representation. You will have to create your own ControlTemplate for the TabControl. You can find a TabControl ControlTemplate Example on MSDN. You will also have to study the Control Authoring Overview on MSDN.

I actually find the Silverlight 3 documentation somewhat easier to digest, and even though there are some differences when it comes to control styling the fundamental concepts are still the same. You can read Customizing the Appearance of an Existing Control by Using a ControlTemplate on MSDN to learn about control templates and then study TabControl Styles and Templates to discover what is required to create you own control template in Silverlight.

You can use Expression Blend to extract the the default TabControl template in WPF.

Martin Liversage
Great writeup that sums up the power and intent of WPF controls nicely. I have yet to be deemed worthy of the ability to up vote, otherwise this is another useful answer I would have given credit to. Maybe I'll remember to come back to this one since it's on my own question if I ever do reach that point.
jan
+7  A: 

You don't need to use a TabControl at all. You could just bind your ListBox to a list of items, and put a ContentControl beside it, bound to the selected item :

<DockPanel>
    <ListBox Name="listBox"
             DockPanel.Dock="Left"
             ItemsSource="{Binding Items}"
             DisplayMemberPath="Name"/>
    <ContentControl Content="{Binding SelectedItem, ElementName=listBox}"
                    ContentTemplate="{StaticResource theTemplate}"/>
</DockPanel>
Thomas Levesque
He-he :). You wrote this faster than I hit "Post Your Answer" button. Just wanted to write about master-details scenario with ListBox, but you made it faster :). Cheers.
Anvaka