Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create a WPF tab control template that looks nothing like a tab control?

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.

like image 482
jan Avatar asked Sep 01 '09 22:09

jan


2 Answers

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.

like image 122
Martin Liversage Avatar answered Nov 02 '22 21:11

Martin Liversage


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>
like image 11
Thomas Levesque Avatar answered Nov 02 '22 21:11

Thomas Levesque