Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: change DateTimeUpDown background OnMouseOver and IsPressed

$
0
0
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>
For the 2nd problem (Mouse click on control behind the TimePicker), I can't reproduce. Can you show a sample of how to reproduce ? I use a TimePicker with a Big Button behind and the Button never calls it's click callback when selecting a time from the TimePicker's listBox.

Viewing all articles
Browse latest Browse all 4964

Trending Articles