2017-02-17 16 views
1

Я использую расширенный CheckComboBox WPF. У меня есть шаблон в ресурсах приложения, в котором я изменил несколько вариантов стилизации, однако я не смог найти, как изменить цвет флажка.CheckComboBox box color

У кого-нибудь есть идея?

Вот шаблон я использую:

<Style x:Key="CheckComboBoxStyle1" TargetType="{x:Type xctk:CheckComboBox}"> 
    <Setter Property="Foreground" Value="White"/> 
    <Setter Property="Background" Value="White"/> 
    <Setter Property="BorderBrush" Value="White"/> 
    <Setter Property="BorderThickness" Value="1"/> 
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/> 
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/> 
    <Setter Property="Padding" Value="2"/> 
    <Setter Property="ScrollViewer.CanContentScroll" Value="True"/> 
    <Setter Property="ScrollViewer.PanningMode" Value="Both"/> 
    <Setter Property="Stylus.IsFlicksEnabled" Value="False"/> 
    <Setter Property="VerticalContentAlignment" Value="Center"/> 
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type xctk:CheckComboBox}"> 
       <Grid x:Name="MainGrid" SnapsToDevicePixels="True"> 
        <Popup x:Name="PART_Popup" AllowsTransparency="True" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom" StaysOpen="False"> 
         <Grid MinWidth="{Binding ActualWidth, ElementName=MainGrid}"> 
          <Border x:Name="DropDownBorder" BorderBrush="White" BorderThickness="1" Background="#676767" MaxHeight="{Binding MaxDropDownHeight, RelativeSource={RelativeSource TemplatedParent}}"> 
           <ScrollViewer x:Name="DropDownScrollViewer"> 
            <Grid RenderOptions.ClearTypeHint="Enabled"> 
             <Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0" Background="#676767"> 
              <Rectangle x:Name="OpaqueRect" Fill="#676767" Height="{Binding ActualHeight, ElementName=DropDownBorder}" Width="{Binding ActualWidth, ElementName=DropDownBorder}"/> 
             </Canvas> 
             <ItemsPresenter x:Name="PART_ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> 
            </Grid> 
           </ScrollViewer> 
          </Border> 
         </Grid> 
        </Popup> 
        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="#676767"/> 
        <ToggleButton x:Name="PART_DropDownButton" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Content="{Binding Text, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Focusable="False" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"> 
         <ToggleButton.IsHitTestVisible> 
          <Binding Path="IsDropDownOpen" RelativeSource="{RelativeSource TemplatedParent}"> 
           <Binding.Converter> 
            <xctk:InverseBoolConverter/> 
           </Binding.Converter> 
          </Binding> 
         </ToggleButton.IsHitTestVisible> 
         <ToggleButton.Style> 
          <Style TargetType="{x:Type ToggleButton}"> 
           <Setter Property="OverridesDefaultStyle" Value="True"/> 
           <Setter Property="IsTabStop" Value="False"/> 
           <Setter Property="Focusable" Value="False"/> 
           <Setter Property="Padding" Value="2"/> 
           <Setter Property="Template"> 
            <Setter.Value> 
             <ControlTemplate TargetType="{x:Type ToggleButton}"> 
              <xctk:ButtonChrome x:Name="Chrome" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="0" RenderNormal="False" RenderMouseOver="{Binding IsMouseOver, ElementName=PART_DropDownButton}" RenderPressed="{Binding IsPressed, ElementName=PART_DropDownButton}" RenderEnabled="{TemplateBinding IsEnabled}" SnapsToDevicePixels="True"> 
               <Grid> 
                <Grid.ColumnDefinitions> 
                 <ColumnDefinition Width="*"/> 
                 <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/> 
                </Grid.ColumnDefinitions> 
                <TextBox x:Name="TextBox" BorderThickness="0" Background="Transparent" Cursor="Arrow" Foreground="{TemplateBinding Foreground}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalScrollBarVisibility="Hidden" IsReadOnly="True" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Text="{Binding Content, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" VerticalScrollBarVisibility="Hidden" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> 
                <Grid Grid.Column="1" HorizontalAlignment="Right" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"> 
                 <Path x:Name="Arrow" Data="M0,1C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1z" Fill="Black" HorizontalAlignment="Center" Margin="3,0" VerticalAlignment="Center"/> 
                </Grid> 
               </Grid> 
              </xctk:ButtonChrome> 
              <ControlTemplate.Triggers> 
               <Trigger Property="IsChecked" Value="True"> 
                <Setter Property="RenderPressed" TargetName="Chrome" Value="True"/> 
               </Trigger> 
               <Trigger Property="IsEnabled" Value="False"> 
                <Setter Property="Fill" TargetName="Arrow" Value="#FFAFAFAF"/> 
               </Trigger> 
               <DataTrigger Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type xctk:CheckComboBox}}}" Value="True"> 
                <Setter Property="IsReadOnly" TargetName="TextBox" Value="False"/> 
                <Setter Property="Focusable" TargetName="TextBox" Value="True"/> 
                <Setter Property="Cursor" TargetName="TextBox" Value="{x:Null}"/> 
               </DataTrigger> 
              </ControlTemplate.Triggers> 
             </ControlTemplate> 
            </Setter.Value> 
           </Setter> 
          </Style> 
         </ToggleButton.Style> 
        </ToggleButton> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
    <Style.Triggers> 
     <Trigger Property="IsMouseOver" Value="True"> 
      <Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey ResourceId=ControlMouseOverBorderKey, TypeInTargetAssembly={x:Type Themes:ResourceKeys}}}"/> 
     </Trigger> 
     <Trigger Property="IsKeyboardFocusWithin" Value="True"> 
      <Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey ResourceId=ControlSelectedBorderKey, TypeInTargetAssembly={x:Type Themes:ResourceKeys}}}"/> 
     </Trigger> 
    </Style.Triggers> 
</Style> 

ответ

0

Там нет особого стиля для галочки. Вы можете стиль их путем добавления неявных CheckBox стиля к CheckComboBox:

<xctk:CheckComboBox> 
    <xctk:CheckComboBox.Resources> 
     <Style TargetType="CheckBox"> 
      <Setter Property="Background" Value="Yellow" /> 
     </Style> 
    </xctk:CheckComboBox.Resources> 
</xctk:CheckComboBox> 
+0

Это сделали это, спасибо! – baerlein