【发布时间】:2012-02-23 14:47:09
【问题描述】:
我的应用程序将在带有触摸屏的计算机上运行,由警察在驾驶时操作。我正在使所有图形元素都变大,这样它们就可以由像我这样的香肠手指和更大的人操作。
我有一个需要出现在屏幕上的CheckBox。我需要缩放复选框的大小和更大的复选标记。我尝试通过右键单击并选择 Edit Template | 来编辑 Expression Blend 中复选框的模板。编辑副本。我设置了副本,使其适用于所有复选框。
我可以通过模板将它的高度和宽度属性绑定到控件的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's 模板。 “编辑当前”和“编辑副本”选项被禁用。
如何完成我想做的事?
托尼
【问题讨论】: