gpt4 book ai didi

wpf - 更改复选框及其中复选标记的大小

转载 作者:行者123 更新时间:2023-12-02 16:58:14 25 4
gpt4 key购买 nike

我的应用程序将在带有触摸屏的计算机上运行,​​由警察在驾驶时操作。我将所有图形元素放大,以便像我这样拥有香肠手指或更大的人可以操作它们。

我有一个需要出现在屏幕上的CheckBox。我需要将复选框和复选标记的大小放大。我尝试通过右键单击并选择编辑模板 | 来编辑 Expression Blend 中复选框的模板。编辑副本。我设置了副本,以便它将应用于所有复选框。

通过模板将框的高度和宽度属性绑定(bind)到控件的ActualHeight,我能够使框变大。然而,复选标记并没有因此而变大,而是位于左上角。至少可以说,它看起来不太正确。

当我编辑模板时,这是我返回的 Xaml:

<Style TargetType="{x:Type CheckBox}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Background" Value="{StaticResource CheckBoxFillNormal}"/>
<Setter Property="BorderBrush" Value="{StaticResource CheckBoxStroke}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FocusVisualStyle" Value="{StaticResource EmptyCheckBoxFocusVisual}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<BulletDecorator Background="Transparent" SnapsToDevicePixels="true">
<BulletDecorator.Bullet>
<Microsoft_Windows_Themes:BulletChrome BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" IsChecked="{TemplateBinding IsChecked}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="{TemplateBinding ActualHeight}" Height="{TemplateBinding ActualHeight}"/>
</BulletDecorator.Bullet>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</BulletDecorator>
<ControlTemplate.Triggers>
<Trigger Property="HasContent" Value="true">
<Setter Property="FocusVisualStyle" Value="{StaticResource CheckRadioFocusVisual}"/>
<Setter Property="Padding" Value="4,0,0,0"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

Expression Blend 不允许我编辑 BulletChrome 的 模板。 “编辑当前”和“编辑副本”选项已禁用。

如何完成我想做的事情?

托尼

最佳答案

默认的 XAML 是 BulletDecorator 的组成示例,可以在 here on MSDN 中找到。 。该页面上几乎整个 XAML block 都处理 BulletDecorator 的外观和行为。

所有 XAML 的核心是两个 Path 对象。第一个用于复选标记,第二个用于不确定标记(尽管名称“InderminateMark”在示例 XAML 中拼写错误。幸运的是,它在 CheckBox 示例中的所有地方都拼写错误,所以没关系。

            <Path Visibility="Collapsed"
Width="7"
Height="7"
x:Name="CheckMark"
SnapsToDevicePixels="False"
StrokeThickness="2"
Data="M 0 0 L 7 7 M 0 7 L 7 0">
<Path.Stroke>
<SolidColorBrush Color="{DynamicResource GlyphColor}" />
</Path.Stroke>
</Path>
<Path Visibility="Collapsed"
Width="7"
Height="7"
x:Name="InderminateMark"
SnapsToDevicePixels="False"
StrokeThickness="2"
Data="M 0 7 L 7 0">
<Path.Stroke>
<SolidColorBrush Color="{DynamicResource GlyphColor}" />
</Path.Stroke>
</Path>

正如 H.B. 所指出的那样在评论中可以找到默认的WPF主题here.

关于wpf - 更改复选框及其中复选标记的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9087063/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com