WPF - 选项卡控件中的两行选项卡 - 选项卡包装

WPF - 选项卡控件中的两行选项卡 - 选项卡包装

问题描述:

我有一个WPF TabControl,其中包含大量选项卡,并且它们在屏幕上以顺序行显示。这意味着用户需要侧向滚动才能查看所有选项卡。WPF - 选项卡控件中的两行选项卡 - 选项卡包装

有没有办法创建两行标签或使长行标签“包装”成两行或多行?

包装是TabControl的默认行为。你正在使用的任何StyleControlTemplate干扰?

以下代码:

<Window x:Class="WpfApplication1.Window1" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="Window1" Height="300" Width="300" AllowsTransparency="True" WindowStyle="None"> 
    <Grid> 
     <TabControl> 
      <TabItem Header="TabItem"/> 
      <TabItem Header="TabItem"/> 
      <TabItem Header="TabItem"/> 
      <TabItem Header="TabItem"/> 
      <TabItem Header="TabItem"/> 
      <TabItem Header="TabItem"/> 
      <TabItem Header="TabItem"/> 
      <TabItem Header="TabItem"/> 
      <TabItem Header="TabItem"/> 
      <TabItem Header="TabItem"/> 
      <TabItem Header="TabItem"/> 
     </TabControl> 
    </Grid> 
</Window> 

产生

Window with many tabs in a tab control http://hypftier.de/dump/wpf_tab_control_wrap.png

+0

事实上,情况是这样。封闭的网格是问题,而不是选项卡控件。 Thanx – 2010-02-18 19:05:54

+0

此解决方案并不总是有效 - 我有一个窗口可以动态改变它的大小(根据标签项的大小),我希望标签可以换成更多的行。 有没有任何方法可以不用硬编码窗口的宽度/ TabControl? – spaarvap 2013-05-26 18:03:59