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

wpf – 更改复选框的大小及其中的复选标记,第1张

概述我的应用程序将在具有触摸风格的计算机上运行,​​由驾驶员在驾驶时 *** 作.我将所有的图形元素都做得更大,这样它们就可以被像我自己和更大的香肠手指一样的人 *** 作. 我有一个需要出现在屏幕上的CheckBox.我需要缩放复选框的大小和复选标记.我尝试通过右键单击并选择Edit Tempate |来编辑Expression Blend中Checkbox的模板编辑副本.我设置了副本,因此它适用于所有复选框. 通 我的应用程序将在具有触摸风格的计算机上运行,​​由驾驶员在驾驶时 *** 作.我将所有的图形元素都做得更大,这样它们就可以被像我自己和更大的香肠手指一样的人 *** 作.

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

通过模板绑定它的高度和高度,我能够使盒子更大. wIDth属性到控件的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"/>                    </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的模板. “编辑当前”和“编辑副本”选项已禁用.

我如何完成我想做的事情?

托尼

解决方法 可以在 here on MSDN找到默认的一个组成BulletDecorator示例的XAML.该页面上几乎整个XAML块都处理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 – 更改复选框的大小及其中的复选标记全部内容,希望文章能够帮你解决wpf – 更改复选框的大小及其中的复选标记所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1118255.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存