Create a tabbed panel with WPF sections

I am trying to create a sidebar with tabs with sections, for example in WPF. There are several approaches that I have reviewed, but is there an easier and more elegant way to do this?

Approach 1: ListBox

Using a ListBox and binding the SelectedItem to the value that the content management is bound to on the right. To distinguish between title and sections, I use the DataTemplate selector.


Approach 2: RadioBUtton / Checkboxes / ToggleButtons

Using the radio buttons, I bind the selected item to the content control. However, due to a WPF error, I will have to bind them together using value converters.


Tabbed Interface Split into Sections

enter image description here

+6
source share
2 answers

Add to that a little more styles, and I think it can work very well.

  <TabControl TabStripPlacement="Left"> <TabControl.Resources> <Style TargetType="TabItem" x:Key="SideBarSectionStyle"> <Setter Property="IsEnabled" Value="False" /> <Setter Property="FontSize" Value="16" /> <Setter Property="Foreground" Value="LightGreen" /> </Style> </TabControl.Resources> <TabItem Header="Section A" Style="{StaticResource SideBarSectionStyle}" /> <TabItem Header="Tab Item 1" IsSelected="True" /> <TabItem Header="Tab Item 2" /> <TabItem Header="Tab Item 3" /> <TabItem Header="Tab Item 4" /> <TabItem Header="Tab Item 5" /> <TabItem Header="Section B" Style="{StaticResource SideBarSectionStyle}" /> <TabItem Header="Tab Item 6" /> <TabItem Header="Tab Item 7" /> <TabItem Header="Tab Item 8" /> <TabItem Header="Tab Item 9" /> </TabControl> 
+2
source

Here are some more ideas:

  • (perhaps the most ideal) Use a treeview and a template for parents and children to hide the extension button. This should help you figure out how to hide them.

  • Instead of using 1 list, use multiple lists with each of them representing a different category of options. You can use the same template or different if you want. In addition, I would keep the title from the list, and let it be a shortcut or something else that sits above the list. You can adjust the field in the list box to indent the parent / child object, such as a tree view.

+1
source

Source: https://habr.com/ru/post/888191/


All Articles