Programmatic Styling of RadDataFilter

5 posts, 0 answers
  1. Mark
    Mark avatar
    44 posts
    Member since:
    Jun 2009

    Posted 31 Jan 2011 Link to this post

    Hello,

    I am trying to apply the Windows 7 theme to the RadDataFilter control.  If I do so in XAML it works fine.  But, if I try to style the control programmatically when the control is loaded (an approach that works for the RadGridView), it does not seem to work.  Does anyone know how I can go about styling the control programmatically?

    The code I am using is as follows:

    // Specify the theme to use for this control.
    Theme theme = ThemeManager.FromName("Windows7");
    if (theme != null)
    {
        StyleManager.SetTheme(this, theme);
    }

    As always, any help, pointers or even thoughts would be appreciated!

    Thanks,
    Mark.



  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 01 Feb 2011 Link to this post

    Hi Mark,

     
    The recommended approach to set a theme on a particular control is the following one:

    StyleManager.SetTheme(this.radDataFilter,new Windows7Theme());


    If you need any additional information please let me know.

    Greetings,
    Vanya Pavlova
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Mark
    Mark avatar
    44 posts
    Member since:
    Jun 2009

    Posted 01 Feb 2011 Link to this post

    Hi Vanya,

    Thanks for your reply, but this code does not really cover my scenario.  The code you poseted looks like you have a control that is wrapping a RadDataFilter (which is what I may have to do).  My scenario is that I have subclassed the RadDataFilter and would like to programmatically set the theme from within myself.  However, no matter where I place the code (constructor, Loaded handler, EditorCreated handler) the contorl always uses the Office Black theme and not the one I set.  I have stepped through the code to see that the call being made to StyleManager.SetTheme gets executed, but does not seem to take effect.  This leads me to believe that perhaps the control itself is initializing the theme sometime after my code gets executed.

    I may try wrapping the RadDataFilter instead of subclassing, but in the meantime, do you have any other insight into what might be happening?

    Thanks,
    Mark
  5. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 02 Feb 2011 Link to this post

    Hi Mark,

     
    Thank you for sharing the details about this issue.

    If you inherit the control, you need to set the DefaultStyleKey in the OnInitialized event:

    override void OnInitialized(EventArgs e)
    {
       base.OnInitialized(e);
       this.DefaultStyleKey = typeof(MyInheritedClass);
    }

    Still, it is better to use composition instead of inheritance.

    Regards,
    Vanya Pavlova
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  6. Mark
    Mark avatar
    44 posts
    Member since:
    Jun 2009

    Posted 02 Feb 2011 Link to this post

    Hi Vanya,

    Thanks for your reply.  This tip seemed promising, but it did not work for me.  I may end up having to simply wrap the control instead.

    Thanks,
    Mark.
Back to Top
UI for WPF is Visual Studio 2017 Ready