2013-08-23 101 views
1

我嘗試使用以下代碼將顏色設置爲xctk:IntegerUpDown控件的邊框。xctk:IntegerUpDown borderbrush不顯示顏色

<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正確顯示,但邊框顏色不按指定顯示。 我一定錯過了什麼。誰能幫忙?

謝謝,

回答

0

可能您使用的版本低於2.0.0。 2.0.0版解決了這個問題。

版本2.0.0您可以下載here

下面是代碼片段,你可以看到在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}}"> 
     ...     
+0

Kmatyaszek,謝謝你這麼多。我正在使用1.8.0。下載了新版本。現在一切正常。欣賞它。 – Shawn