Ric*_*gan 57 wpf user-interface
我将.ContentLabel 的值设置为包含下划线的字符串; 第一个下划线被解释为加速键.
如果没有(更换所有改变基础字符串_用__),是有办法禁用标签加速器?
小智 80
如果使用TextBlock作为Label的内容,则其Text不会吸收下划线.
den*_*ips 28
您可以覆盖ContentPresenter的RecognizesAccessKey属性,该属性位于标签的默认模板中.例如:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.Resources>
<Style x:Key="{x:Type Label}" BasedOn="{StaticResource {x:Type Label}}" TargetType="Label">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Label">
<Border>
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="False" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Label>_This is a test</Label>
</Grid>
</Page>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27209 次 |
| 最近记录: |