Quantcast
Channel: wpftoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 2157

New Post: Change Button Background on DateTimePicker and TimePicker

$
0
0
Greetings BoucherS, the code you posted works for the small spinner buttons, can you post the code that targets the bigger drop down buttons that are to the right of the spinner buttons. So the color change affects the spinner and drop down buttons.

BoucherS wrote:
Hi,

Here's a solution on how to modify the RepeatButtons background when they are mousedOver or pressed :
<Window x:Class="WpfApplication34.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes;assembly=Xceed.Wpf.Toolkit"
        Title="MainWindow" Height="350" Width="525">
   <Window.Resources>
      <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type themes:ResourceKeys}, ResourceId=SpinnerButtonStyleKey}"
             TargetType="RepeatButton">
         <Setter Property="Background"
                 Value="Red" />
         <Setter Property="BorderBrush"
                 Value="Black" />
         <Setter Property="BorderThickness"
                 Value="1" />
         <Setter Property="Padding"
                 Value="2,2" />
         <Setter Property="Template">
            <Setter.Value>
               <ControlTemplate TargetType="RepeatButton">
                  <Grid>
                     <xctk:ButtonChrome x:Name="Chrome"
                                          BorderBrush="{TemplateBinding BorderBrush}"
                                          Background="{TemplateBinding Background}"
                                          CornerRadius="{DynamicResource {x:Static themes:ResourceKeys.SpinButtonCornerRadiusKey}}"
                                          SnapsToDevicePixels="true" />

                     <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                       VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                       Margin="{TemplateBinding Padding}" />
                  </Grid>
                  <ControlTemplate.Triggers>
                     <Trigger Property="IsMouseOver"
                              Value="True">
                        <Setter Property="Background"
                                Value="Green" />
                     </Trigger>
                     <Trigger Property="IsPressed"
                              Value="True">
                        <Setter Property="Background"
                                Value="Blue" />
                     </Trigger>
                  </ControlTemplate.Triggers>
               </ControlTemplate>
            </Setter.Value>
         </Setter>
      </Style>

   </Window.Resources>
    <Grid>
      <xctk:TimePicker Width="150"
                                  Height="22" />
   </Grid>
</Window>

Viewing all articles
Browse latest Browse all 2157

Trending Articles