C#   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c# – 禁用/覆盖WPF控件上的突出显示大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_696_2@
我有一个带有ScrollViewer.VerticalScrollBarVisibility = Auto的RichTextBox,这就像我想要的那样工作.但是,当我将鼠标悬停在文档上时,我在整个RichTextBox元素周围得到一个蓝色边框,而我似乎唯一能让它消失的方法是设置IsHitTestVisible = false,但如果我这样做,滚动条也会被禁用…我尝试过的其他事情是IsFocusable = false并触发RichTextBox的样式,但没有任何成功:

<Style.triggers>
    <trigger Property="IsMouSEOver" Value="True">
        <Setter Property="BorderBrush" Value="{x:Null}"/>
    </trigger>
</Style.triggers>

我的应用程序中的图像与ListBox显示的问题相同.我有一个ListBox看起来像这样

<ListBox Items@R_450_9016@e="{Binding Photos}"
         BorderBrush="{x:Null}"
         SELEctedItem="{Binding SELEctedPhoto,Mode=TwoWay}">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <UniformGrid IsItemsHost="True" 
                         HorizontalAlignment="Center" 
                         VerticalAlignment="Center" 
                         columns="3" Rows="1"/>
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.ItemTemplate>
        <DataTemplate>
            <Image @R_450_9016@e="{Binding}" 
                   Stretch="Uniform" 
                   SnapsToDevicePixels="True"/>
        </DataTemplate>
    </ListBox.ItemTemplate>
    <ListBox.ItemContainerStyle>
        <Style TargetType="ListBoxItem">
            <Style.resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
                                 Color="Transparent"/>
            </Style.resources>
            <Setter Property="Foreground" Value="Transparent"/>
            <Setter Property="BorderBrush" Value="{Staticresource Brush_Secondary}"/>
            <Setter Property="BorderThickness" Value="5"/>
            <Setter Property="Margin" Value="5"/>
            <Style.triggers>
                <trigger Property="IsMouSEOver" Value="True">
                    <Setter Property="BorderBrush" Value="{Staticresource Brush_PriMary}"/>
                </trigger>
                <trigger Property="IsSELEcted" Value="True">
                    <Setter Property="BorderBrush" Value="{Staticresource Brush_SELEcteD}"/>
                </trigger>
            </Style.triggers>
        </Style>
    </ListBox.ItemContainerStyle>
</ListBox>

但无论我使用哪种颜色(Brush_PriMary / Secondary / SELEcted),边框总是只有不同的蓝色阴影……如何摆脱每个WPF控件似乎存在的蓝色叠加/突出显示

@H_696_2@

解决方法

您可以覆盖RichTextBox模板以删除认值 –

<Style TargetType="RichTextBox">
   <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <Border x:Name="Bd"
                        BorderBrush="{TemplateBinding BorderBrush}" 
                        BorderThickness="{TemplateBinding BorderThickness}"
                        SnapsToDevicePixels="True"
                        BACkground="{TemplateBinding BACkgrounD}">
                    <ScrollViewer Name="PART_ContentHost"/>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
@H_696_2@ @H_696_2@
@H_696_2@
@H_696_2@

大佬总结

以上是大佬教程为你收集整理的c# – 禁用/覆盖WPF控件上的突出显示全部内容,希望文章能够帮你解决c# – 禁用/覆盖WPF控件上的突出显示所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。