在标签控件中,我必须在屏幕截图中添加+按钮。我将加号按钮添加到选项卡面板,当我运行程序并选择选项卡项时,选项卡控件边框不像普通选项卡控件那样隐藏。请查看附带的屏幕截图,以明确我的问题。
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid
x:Name="templateRoot"
ClipToBounds="true"
KeyboardNavigation.TabNavigation="Local"
SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnDefinition0" />
<ColumnDefinition x:Name="ColumnDefinition1" Width="0" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="RowDefinition0" Height="Auto" />
<RowDefinition x:Name="RowDefinition1" Height="*" />
</Grid.RowDefinitions>
<StackPanel
x:Name="headerPanel"
Grid.Row="0"
Grid.Column="0"
Orientation="Horizontal">
<TabPanel
x:Name="_HeaderPanel"
Panel.ZIndex="1"
IsItemsHost="true"
KeyboardNavigation.TabIndex="1" />
<Button
x:Name="addButton"
Width="50"
Height="30"
Background="LightGray"
BorderBrush="LightGray"
BorderThickness="1,0,0,0"
Command="{Binding ChartAddButton_Click}"
Content="+" />
</StackPanel>
<Border
x:Name="contentPanel"
Grid.Row="1"
Grid.Column="0"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
KeyboardNavigation.DirectionalNavigation="Contained"
KeyboardNavigation.TabIndex="2"
KeyboardNavigation.TabNavigation="Local">
<ContentPresenter
x:Name="PART_SelectedContentHost"
Margin="{TemplateBinding Padding}"
ContentSource="SelectedContent"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</Grid>
通过将加号按钮添加到选项卡面板,将会发生这种情况。如何解决这个问题。请提出你的建议。
答案 0 :(得分:0)
我假设你指的是虚线。这不是显示的边框,我认为这是Button的默认FocusVisualStyle
。
尝试设置,
FocusVisualStyle = "{x:null}"
按钮上的。