Overriding Control Template in a Custom Control Library not working

2 posts, 0 answers
  1. Eric Bush
    Eric Bush avatar
    3 posts
    Member since:
    May 2010

    Posted 30 Jul 2010 Link to this post

    I have the following derivation that includes the customary static constructor.


    public class CustomRadDatePicker : RadDatePicker



    static CustomRadDatePicker()








    new FrameworkPropertyMetadata(typeof(CustomRadDatePicker))); // also tried RadDatePicker here



    In the XAML for the controls template I have the following.




    <Style TargetType="{x:Type SharedControls:CustomRadDatePicker}">




    <Setter Property="Template">














    <ControlTemplate TargetType="{x:Type SharedControls:CustomRadDatePicker}">

    Now when I use the control on a page it does not use the style I have set up but is using the Telerik style.
    I have my derived control and its template set up in a WPF custom control library.
    Is it allowed to override the Teleric Style?



  2. George
    George avatar
    1332 posts

    Posted 05 Aug 2010 Link to this post

    Hi Eric Bush,

    Thank you for contacting us.
    You could override OnInitialized method, call the base OnInitialized and after that set the DefaultStyleKey.
    For example: 

    protected override void OnInitialized(EventArgs e)
                this.DefaultStyleKey = typeof(CustomRadDatePicker);

    I hope this helps!

    Best wishes,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top