WPF 中未显示下划线 [英] Underscores not displayed in WPF
本文介绍了WPF 中未显示下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的整个应用程序中,我有一些未显示的下划线 (_).
On my whole application, I've some underscores (_) which are not displayed.
这是由于访问器.但是我怎样才能禁用它?应用广泛?我没有在标签、文本框、...
It's due to the accessor. But how can I disable it? Application wide? I don't have them on labels, textboxes, ...
谢谢
推荐答案
要全局禁用所有标签的下划线,您可以覆盖标签的默认模板,如下所示:
To disable underscores globally for all labels you can override the default template for labels like this:
<Style x:Key="{x:Type Label}"
TargetType="{x:Type Label}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Label}">
<Border Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="False"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled"
Value="false">
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
它不同于这一行的默认模板:RecognizesAccessKey="False"
.
It differs from the default template in this line: RecognizesAccessKey="False"
.
将此样式放入应用程序的全局资源 (App.xaml
) 中,您的标签将不再识别下划线.
Put this style in global resources of your application (App.xaml
) and your labels will not recognize underscores anymore.
这篇关于WPF 中未显示下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文