wpf 如何将多个选项卡控件添加到一个 window

wpf how to add multiple tabcontrols to one window

所以,现在我的左边有标签。但是,我想要屏幕顶部的选项卡,因为这些是我想要实现的不同控件。我试着在我的网格中添加另一个选项卡控件,但布局完全搞砸了,none 选项卡不再工作了。

有什么解决办法吗?

<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>

多个选项卡控件工作 - 您现在只需要按您希望的方式对它们进行分层排序。 例如,这个 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>

看起来像这样: