0

Here is my MainWindow.xaml

<Window x:Class="DatePicker.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:DatePicker"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Styles/FormElements.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Grid>
        <DatePicker HorizontalAlignment="Left" Margin="127,59,0,0" VerticalAlignment="Top" >

        </DatePicker>
    </Grid>
</Window>

And I wan to load the styles from FormElements.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style TargetType ="{x:Type DatePicker}">
        <Setter Property="Height" Value="24" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Background" Value="Red"/>
    </Style>

    <Style TargetType="{x:Type DatePickerTextBox}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <TextBox x:Name="PART_TextBox" IsReadOnly="True" Text="{Binding Path=SelectedDate, TargetNullValue='mm/dd/yyyy', StringFormat={}{0:MM/dd/yyyy}, RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}}" BorderThickness="0"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>

How can I control the PREV & NEXT button on the calendar popup? I would like to change the PREV & NEXT buttons (only those)

Here is a the project code link

HaBo
  • 13,999
  • 36
  • 114
  • 206
  • Did you read this?: https://msdn.microsoft.com/en-us/magazine/dd882520.aspx – mm8 Feb 09 '17 at 11:42
  • What are you exactly trying to do with the previous and next buttons? Here is a sample for customizing the buttons https://www.codeproject.com/Articles/1070720/CUSTOMIZING-THE-WPF-DATEPICKER – Suresh Kumar Veluswamy Feb 09 '17 at 11:58
  • I want to change the icon for PART_PreviousButton & PART_NextButton, examples you both shared here are heavy changes, I don't want to change the look entirely, I want to know if I can just add a icon for PART_PreviousButton & PART_NextButton – HaBo Feb 09 '17 at 12:03
  • You cannot modify only a part of a control template. You must (re)define the entire template as a whole: http://stackoverflow.com/questions/41570096/wpf-is-there-a-way-to-override-part-of-a-controltemplate-without-redefining-the – mm8 Feb 09 '17 at 13:07

0 Answers0