【问题标题】:TabControl Border is not hidden when adding the new button(add button) in tabpanel in wpf在 wpf 的 tabpanel 中添加新按钮(添加按钮)时,TabControl 边框不隐藏
【发布时间】:2018-05-10 12:37:42
【问题描述】:

在选项卡控件中,我必须将 + 按钮添加到选项卡项,如屏幕截图所示。我在选项卡面板中添加了加号按钮,当我运行程序并选择选项卡项时,选项卡控件边框不像普通选项卡控件那样隐藏。请检查随附的屏幕截图以明确我的问题。

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

通过将加号按钮添加到选项卡面板,这将发生。如何解决这个问题。请提出您的建议。

Please refer the updated screenshot

【问题讨论】:

    标签: c# xaml tabcontrol


    【解决方案1】:

    我假设您指的是虚线。那不是正在显示的边框,我认为这是 Button 的默认 FocusVisualStyle

    尝试设置,

    FocusVisualStyle = "{x:null}"
    

    在按钮上。

    【讨论】:

    • 我没有提到虚线。请参考我更新的截图。
    • 有什么建议吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-04
    • 2011-03-28
    • 1970-01-01
    相关资源
    最近更新 更多