1

我尝试使用以下代码将颜色设置为 xctk:IntegerUpDown 控件的边框。

<Style TargetType="{x:Type xctk:IntegerUpDown}" >
    <Setter Property="Background" Value="{StaticResource WindowBrush}" />
    <Setter Property="Foreground" Value="{StaticResource TextBrush}" />
    <Setter Property="BorderBrush" Value="Green"/>
    <Setter Property="BorderThickness" Value="5"/>
</Style>

BorderThickness 显示正确,但边框颜色未按指定显示。我肯定错过了什么。任何人都可以帮忙吗?

谢谢,

4

1 回答 1

0

可能您使用的版本低于 2.0.0。2.0.0 版解决了这个问题。

版本 2.0.0 你可以在这里下载。

下面是代码片段,您可以看到 2.0.0 以下版本缺少与模板 BorderBrush ( BorderBrush="{TemplateBinding BorderBrush}") 的绑定。

2.0.0版本实现(源码):

<Style x:Key="NumericUpDown" TargetType="{x:Type prim:InputBase}">
  <Setter Property="Background" Value="{DynamicResource {x:Static themes:ResourceKeys.ControlNormalBackgroundKey}}" />
  <Setter Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ControlNormalBorderKey}}" />
  <Setter Property="BorderThickness" Value="1" />
  <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
  <Setter Property="HorizontalContentAlignment" Value="Right" />
  <Setter Property="IsTabStop" Value="False" />
  <Setter Property="VerticalContentAlignment" Value="Center" />
  <Setter Property="TextAlignment" Value="Right" />
  <Setter Property="WatermarkTemplate" Value="{StaticResource DefaultWatermarkTemplate}" />
    <Setter Property="Template">
     <Setter.Value>
        <ControlTemplate TargetType="Control">
           <local:ButtonSpinner x:Name="PART_Spinner"
                                IsTabStop="False"
                                Background="{TemplateBinding Background}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                AllowSpin="{Binding AllowSpin, RelativeSource={RelativeSource TemplatedParent}}"
                                ShowButtonSpinner="{Binding ShowButtonSpinner, RelativeSource={RelativeSource TemplatedParent}}">

               ...

1.9.0版本实现(源码):

<Style x:Key="NumericUpDown" TargetType="{x:Type prim:InputBase}">
      <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
      <Setter Property="BorderThickness" Value="1" />
      <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
      <Setter Property="HorizontalContentAlignment" Value="Right" />
      <Setter Property="IsTabStop" Value="False" />
      <Setter Property="VerticalContentAlignment" Value="Center" />
      <Setter Property="TextAlignment" Value="Right" />
      <Setter Property="WatermarkTemplate" Value="{StaticResource DefaultWatermarkTemplate}" />      
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="Control">
               <local:ButtonSpinner x:Name="PART_Spinner"
                                    IsTabStop="False"
                                    Background="{TemplateBinding Background}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    AllowSpin="{Binding AllowSpin, RelativeSource={RelativeSource TemplatedParent}}"
                                    ShowButtonSpinner="{Binding ShowButtonSpinner, RelativeSource={RelativeSource TemplatedParent}}">
        ...                
于 2013-08-23T15:11:45.997 回答