[英]tab of TabControl at the bottom in WPF
我使用WPF(C#)。
我想選項卡TabControl位於底部。 為此,我使用屬性: TabStripPlacement =“ Bottom” 。
但是,由於我的風格,此屬性不起作用:
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type TabControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid KeyboardNavigation.TabNavigation="Local">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TabPanel IsItemsHost="True" />
<ContentPresenter Grid.Row="1" ContentSource="SelectedContent"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<TabControl TabStripPlacement="Bottom" >
<TabItem Header="tab1">fff</TabItem>
<TabItem Header="tab2"></TabItem>
<TabItem Header="tab3"></TabItem>
</TabControl>
</Grid>
請告訴我, 如何修復位於底部的 TabControls選項卡 ?
將Grid.Row="1"
移動到<TabPanel...>
元素:
<TabPanel Grid.Row="1" IsItemsHost="True" />
<ContentPresenter ContentSource="SelectedContent"/>
然后,選項卡將顯示在內容下方。
將您的控制模板更新為:
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type TabControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid KeyboardNavigation.TabNavigation="Local">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ContentPresenter ContentSource="SelectedContent"/>
<TabPanel Grid.Row="1" IsItemsHost="True" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<TabControl TabStripPlacement="Bottom" >
<TabItem Header="tab1">fff</TabItem>
<TabItem Header="tab2"></TabItem>
<TabItem Header="tab3"></TabItem>
</TabControl>
</Grid>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.