Style for DatePicker

2 posts, 0 answers
  1. Dan M
    Dan M avatar
    4 posts
    Member since:
    Sep 2009

    Posted 07 Mar 2011 Link to this post

    I am trying to apply a Theme to the DatePicker control but I also want to hide the week numbers in the calendar pop-up. This is the code

    <Window x:Class="WPF_RadDateTimePicker.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
            xmlns:local="clr-namespace:WPF_RadDateTimePicker"
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <Style x:Key="calendarStyle" TargetType="telerik:RadCalendar">           
                <Setter Property="AreWeekNumbersVisible" Value="False" />
            </Style>
        </Window.Resources>
     
        <StackPanel>        
            <telerik:RadDateTimePicker Width="100" VerticalAlignment="Center"
                                       CalendarStyle="{StaticResource calendarStyle}"
                                       telerik:StyleManager.Theme="Expression_Dark"/>
        </StackPanel>
    </Window>
    
    As soon as I reffer to the static calendarStyle the Expression_Dark theme is no longer correctly applied to the Calendar control
    otherwise works fine. How can I fix this?? ( I using 2010 Q3 version of the product)
  2. Dani
    Admin
    Dani avatar
    848 posts

    Posted 11 Mar 2011 Link to this post

    Hello Dan,

    You will need to base your CalendarStyle on the Expression theme to prevent the style from overriding the theme. Use the ThemeResourceKey as follows:

    <Style x:Key="CalendarStyle" TargetType="telerik:RadCalendar" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Expression_DarkTheme, ElementType=telerik:RadCalendar}}">           
              <Setter Property="AreWeekNumbersVisible" Value="False" />
    </Style>


    Regards,
    Dani
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top