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

Can't override NoDataControlStyle

5 Answers 86 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 02 Mar 2012, 11:22 PM
Hello,

Is it not possible to change the style of the NoDataControlStyle when a theme has been set on the parent chart?

I have a style defined in my UserControl.Resources section of my XAML:
<UserControl.Resources>
  ...
        <Style TargetType="telerikCharting:NoDataControl" x:Key="NoDataControlStyle">

And then the Metro theme for my chart with the style set on NoDataControlStyle:

<telerikChart:RadChart x:Name="radChart" telerik:StyleManager.Theme="Metro">
 
...
 
<telerikCharting:ChartDefaultView.ChartArea>
     <telerikCharting:ChartArea NoDataControlStyle="{StaticResource NoDataControlStyle}" IsNoDataMessageEnabled="True" NoDataString="My NoData text" EnableAnimations="False">

The end result is always that my NoDataControlStyle has the Metro theme...

I have tried setting the style in code behind as well and it didn't change the behavior.

Thanks!

Chris

5 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 07 Mar 2012, 02:32 AM
Any ideas on this?  Do I need to build a custom Metro theme in order to do this or should I be able to set NoDataControlStyle seperately here? 

Thanks!

Chris
0
Evgenia
Telerik team
answered on 07 Mar 2012, 02:56 PM
Hi Chris,

Try setting ApplicationTheme in your project before InitializeComponent();

StyleManager.ApplicationTheme = new MetroTheme();
and remove all telerik:Theming.Theme="Metro".

Regards,
Evgenia
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Chris
Top achievements
Rank 1
answered on 07 Mar 2012, 08:38 PM

That works to help fix the issues with the chart (sets the Metro theme for the chart and uses my custom NoDataControlStyle)! :)  It creates a new problem for me though which is that it affects the style of other objects in the application.  The chart control is hosted in a RadDock and when I set the StyleManager.ApplicationTheme in the chart control it changes the style of that parent dock control to Metro as well which I don't want.

I read the docs on StyleManager.ApplicationTheme and there seems to be a way to set it on a per control basis:

StyleManager.SetTheme(this.radChart, new MetroTheme());

The problem with this though is that I can't do that before InitializeComponent() because I get a nullref trying to apply it to the radChart object.  If I do it *AFTER* the InitializeComponent() call I have the same original issue which is that the NoDataControlStyle gets set to Metro as well. 

0
Accepted
Sia
Telerik team
answered on 12 Mar 2012, 05:46 PM
Hello Chris,

Unfortunately the observed behavior is limitation of our theming mechanism.

An instance theme always should be set after the InitializeComponent() call and an application theme should be set before it. Can you please try to set our Metro theme as application theme and at the same time set the needed one to the RadDock control?

Kind regards,
Sia
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Chris
Top achievements
Rank 1
answered on 13 Mar 2012, 05:04 AM
Perfect!  That worked - Thanks!
Tags
Chart
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Evgenia
Telerik team
Sia
Telerik team
Share this question
or