Can't override NoDataControlStyle

6 posts, 1 answers
  1. Chris
    Chris avatar
    16 posts
    Member since:
    Apr 2008

    Posted 02 Mar 2012 Link to this post

    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
  2. Chris
    Chris avatar
    16 posts
    Member since:
    Apr 2008

    Posted 06 Mar 2012 Link to this post

    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
  3. DevCraft banner
  4. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 07 Mar 2012 Link to this post

    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 >>
  5. Chris
    Chris avatar
    16 posts
    Member since:
    Apr 2008

    Posted 07 Mar 2012 Link to this post

    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. 

  6. Answer
    Sia
    Admin
    Sia avatar
    667 posts

    Posted 12 Mar 2012 Link to this post

    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 >>
  7. Chris
    Chris avatar
    16 posts
    Member since:
    Apr 2008

    Posted 13 Mar 2012 Link to this post

    Perfect!  That worked - Thanks!
Back to Top
DevCraft banner