【问题标题】:xctk:IntegerUpDown borderbrush does not show colorxctk:IntegerUpDown 边框刷不显示颜色
【发布时间】:2013-08-23 02:23:48
【问题描述】:

我尝试使用以下代码为 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 显示正确,但边框颜色未按指定显示。 我肯定错过了什么。有人可以帮忙吗?

谢谢,

【问题讨论】:

    标签: wpf c#-4.0 wpftoolkit


    【解决方案1】:

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

    2.0.0版可以下载here。

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

    2.0.0 版实现 (source code):

    <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 版实现 (source code):

    <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}}">
            ...                
    

    【讨论】:

    • Kmatyaszek,非常感谢。我使用的是 1.8.0。下载了新版本。现在一切正常。欣赏它。
    猜你喜欢
    • 1970-01-01
    • 2012-12-27
    • 1970-01-01
    • 2012-11-10
    • 1970-01-01
    • 2021-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多