How to select a theme?

5 posts, 0 answers
  1. James
    James avatar
    7 posts
    Member since:
    Mar 2011

    Posted 22 Jul 2011 Link to this post

    Within your demo for the RadCalendar, it allows you to select any of several themes, but I don't see anything within the Code example to accomplish that. How can we select a specific theme from amongst those samples -- such as Office Blue or Transparent?  And how do we do this at run-time?

    Also, in following the code example that illustrates the EventDayTemplateSelector, - it sets the DataTemplate to a TextBlock. But how would we set the appearance of the entire block that a given day appears in, in the sense that the blocks would abut one another if on adjacent days (does that sound confusing? does to me. In other words - I want to use the entire day-area to put a graphic indication of what kind of event is set for that day).

    Thank you for your help,

    James W. Hurst

    VS 2010, Win 7 x64, RadControls for WPF Q2 2011
  2. Dani
    Admin
    Dani avatar
    848 posts

    Posted 27 Jul 2011 Link to this post

    Hello James,

    Changing the theme at runtime for RadControls requires that you recreate your content so that the controls can pick up the new theme and get redrawn. So the following is needed:

    • - Have a property in your ViewModel which is of type Telerik.Windows.Controls.Theme and use it to keep your current theme.
    • - Have StackPanel with RadioButtons , for example,  in your View that will present all options for the themes.
    • - Create a Command for each of the RadioButtons. The single purpose of the command will be to update the currentTheme property.
    • - Bind the Theme property of the control you wish to change the theme for in the following manner:
    <telerik:RadCalendar  telerik:StyleManager.Theme="{Binding CurrentTheme}" /> 

    On your question regarding RadCalendar FirstLook example - I am sorry, but I am not sure I understand what exactly you mean by a day block. Could you send a screenshot of what you wish to achieve or simply share more details. Basically, you could include a graphic indication for the type of day / event in the day button itself. You could use the DayButtonStyle or DayButtonStyleSelector for the purpose.

    I hope this helps.

    Kind regards,
    Dani
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. UI for WPF is Visual Studio 2017 Ready
  4. James
    James avatar
    7 posts
    Member since:
    Mar 2011

    Posted 03 Aug 2011 Link to this post

    Thank you - your advice was a great help in guiding me to set the theme of the calendar dynamically.

    How do we persist the value of a Telerik Theme object, though, via XML?  I see within your API that there is a ThemeSerializer; is there an example somewhere of how to use that?  I want to save the theme value that was selected by the user, from one invocation of the program to the next.

    By "day block" - I suppose I mean a 'day button'. ?   I'm referring to the square area within the calendar that displays a day-of-the-month. Presently, it displays a simple number. I see how to set the style for the TextBlock (bold, font, etc.) -- but what I wind up with is still a small number inside a large area (relatively speaking).  What I am wanting to do, is show graphics within that area to indicate when there are events for that day, taking up the entire area.
  5. Dani
    Admin
    Dani avatar
    848 posts

    Posted 04 Aug 2011 Link to this post

    Hello James,

    I am afraid it is not possible to use the Theme through XML, our theming mechanism does not support that approach. I suggest you use the conventional way of saving user's choice of theme - using MVVM pattern, you could have a property in your ViewModel that will be of type Theme and will be responsible for the current theme. It will also update all controls when the theme changes, if you set the telerik:StyleManager.Theme property in each control like this:
    <scheduleView:RadScheduleView  telerik:StyleManager.Theme="{Binding CurrentTheme}" 
                                           AppointmentsSource="{Binding Appointments}"
    ...
    </scheduleView:RadScheduleView>

    To change the appearance of the day button, you should modify the DayButtonStyle. You can get that style from Expression Blend by clicking Edit Additonal Template > Edit DayButtonStyle. In the control template of the style, add your own visual element  and make it visible whenever your scenario requires it. The DayButtonStyle is applied to all buttons in the calendar view, so in case you wish to apply it to a particular type of days only, you will also need a DayButtonStyleSelector to distinguish between the days and their visual representation.

    I hope this information will be helpful.

    All the best,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
  6. Dani
    Admin
    Dani avatar
    848 posts

    Posted 04 Aug 2011 Link to this post

    Hi James,

    I also attach a basic sample illustrating the use of DayButtonStyle for WPF. I hope you find it helpful.

    Regards,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
Back to Top
UI for WPF is Visual Studio 2017 Ready