This is a migrated thread and some comments may be shown as answers.

Programmatic Styling of RadDataFilter

4 Answers 103 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 31 Jan 2011, 10:16 PM
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.



4 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 01 Feb 2011, 05:24 PM
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>>
0
Mark
Top achievements
Rank 1
answered on 01 Feb 2011, 10:50 PM
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
0
Vanya Pavlova
Telerik team
answered on 02 Feb 2011, 05:32 PM
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>>
0
Mark
Top achievements
Rank 1
answered on 02 Feb 2011, 06:01 PM
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.
Tags
DataFilter
Asked by
Mark
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Mark
Top achievements
Rank 1
Share this question
or