2016-08-15 89 views
0

所以,現在我有標籤左側。不過,我希望我的屏幕頂部有標籤,因爲這些是我想要實現的不同控件。我試着在我的網格中添加另一個tabcontrol,但佈局完全搞砸了,沒有任何標籤工作了。wpf如何添加多個tabcontrols到一個窗口

任何解決方案?

<Window x:Class="Berichtensysteem.Window1" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:local="clr-namespace:Berichtensysteem" 
     mc:Ignorable="d" 
     Title="Mailclient" Height="auto" Width="auto" 
     > 

     <Grid Height="400" Width="600"> 

     <TabControl TabStripPlacement="Left" > 
      <TabItem Header="Inbox" Height="30"> 
       <TabItem.Content> 
        <ListView Name="inbox" BorderThickness="2"> 
         <ListView.View > 
          <GridView> 
           <GridViewColumn Header="From" Width="70" DisplayMemberBinding="{Binding from}" /> 
           <GridViewColumn Header="Subject" Width="120" DisplayMemberBinding="{Binding subject}" /> 
           <GridViewColumn Header="Content" Width="150" DisplayMemberBinding="{Binding content}" /> 
          </GridView> 
         </ListView.View> 
        </ListView> 
       </TabItem.Content> 
      </TabItem> 
      <TabItem Header="Verzonden items" Height="30"> 
       <TabItem.Content> 
        <ListView Name="sentitems" BorderThickness="2"> 
         <ListView.View> 
          <GridView> 
           <GridViewColumn Header="From" Width="70" DisplayMemberBinding="{Binding from}" /> 
           <GridViewColumn Header="Subject" Width="120" DisplayMemberBinding="{Binding subject}" /> 
           <GridViewColumn Header="Content" Width="150" DisplayMemberBinding="{Binding content}" /> 
          </GridView> 
         </ListView.View> 
        </ListView> 
       </TabItem.Content> 
      </TabItem> 
      <TabItem Header="Verwijderde Items" Height="30" 
        > 
       <TabItem.Content> 
        <ListView Name="deleteditems" BorderThickness="2"> 
         <ListView.View> 
          <GridView> 
           <GridViewColumn Header="From" Width="70" DisplayMemberBinding="{Binding from}" /> 
           <GridViewColumn Header="Subject" Width="120" DisplayMemberBinding="{Binding subject}" /> 
           <GridViewColumn Header="Content" Width="150" DisplayMemberBinding="{Binding content}" /> 
          </GridView> 
         </ListView.View> 
        </ListView> 
       </TabItem.Content> 
      </TabItem> 
     </TabControl> 
    </Grid> 

</Window> 
+0

你可以創建你想達到什麼草圖? (ProTip - 轉到[ux.stackexchange]並使用內置於詢問/回答中的工具)。 – ChrisF

+0

多個選項卡控件工作得很好。你做了什麼沒有奏效? –

回答

2

多個標籤控件的工作 - 你只需要現在你想如何分層次排列他們。 例如,此XAML:

<Window x:Class="WpfApplication3.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:local="clr-namespace:WpfApplication3" 
    mc:Ignorable="d" 
    Title="MainWindow" Height="350" Width="525"> 
<Grid Height="400" Width="600"> 
    <TabControl> 
     <TabItem Header="Folders" Height="30"> 
      <TabItem.Content> 
       <TabControl TabStripPlacement="Left" > 
        <TabItem Header="Inbox" Height="30"> 
        <TabItem.Content> 
          <ListView Name="inbox" BorderThickness="2"> 
           <ListView.View > 
            <GridView> 
             <GridViewColumn Header="From" Width="70" DisplayMemberBinding="{Binding from}" /> 
             <GridViewColumn Header="Subject" Width="120" DisplayMemberBinding="{Binding subject}" /> 
             <GridViewColumn Header="Content" Width="150" DisplayMemberBinding="{Binding content}" /> 
            </GridView> 
           </ListView.View> 
          </ListView> 
         </TabItem.Content> 
        </TabItem> 
        <TabItem Header="Verzonden items" Height="30"> 
         <TabItem.Content> 
          <ListView Name="sentitems" BorderThickness="2"> 
           <ListView.View> 
            <GridView> 
             <GridViewColumn Header="From" Width="70" DisplayMemberBinding="{Binding from}" /> 
             <GridViewColumn Header="Subject" Width="120" DisplayMemberBinding="{Binding subject}" /> 
             <GridViewColumn Header="Content" Width="150" DisplayMemberBinding="{Binding content}" /> 
           </GridView> 
          </ListView.View> 
          </ListView> 
         </TabItem.Content> 
       </TabItem> 
        <TabItem Header="Verwijderde Items" Height="30" 
       > 
         <TabItem.Content> 
          <ListView Name="deleteditems" BorderThickness="2"> 
           <ListView.View> 
            <GridView> 
             <GridViewColumn Header="From" Width="70" DisplayMemberBinding="{Binding from}" /> 
             <GridViewColumn Header="Subject" Width="120" DisplayMemberBinding="{Binding subject}" /> 
             <GridViewColumn Header="Content" Width="150" DisplayMemberBinding="{Binding content}" /> 
            </GridView> 
           </ListView.View> 
          </ListView> 
         </TabItem.Content> 
        </TabItem> 
       </TabControl> 
       </TabItem.Content> 
      </TabItem> 
     <TabItem Header="Second Tab"> 
     </TabItem> 
    </TabControl> 
</Grid> 

看起來就像是:

enter image description here

+0

啊,他們的關鍵是嵌套他們。謝謝 – user3117628

相關問題