Apply themes on RadControls Q1 2009

45 posts, 1 answers
  1. Rogério
    Rogério avatar
    33 posts
    Member since:
    Feb 2009

    Posted 12 Mar 2009 Link to this post

    Hello,

    I've just installed the new RadControls Q1 2009 and tried to change the sample application theme!
    I already checked several posts regarding theming but I could not find any answer to my problem.
    Example:
    http://www.telerik.com/community/forums/silverlight/window/change-theme-of-radwindow.aspx

    It seams that something changed on this version!

    Could you explain what should I do on this version?

    Thanks.
  2. Answer
    Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 13 Mar 2009 Link to this post

    Hi Rogério,

    We have made some modifications in theming mechanism in this release (Q1 2009).
    There are two ways that you can use to change the application theme.
    The first way is to use StyleManager.ApplicationTheme property:
    StyleManager.ApplicationTheme = ThemeManager.FromName("Vista"); 
    Put this line in the Application constructor (before InitializeComponent method).

    With this release we shipped three predefined themes: Vista, Summer and Office_Black (this is the default theme). You can use ThemeManager.FromName method with this three keys. FromName will return Theme object with predefined source property.

    The second way is to use directly the Theme class:
    Theme cutomTheme = new Theme(new Uri("/MyCustomThemeAssembly;component/Themes/generic.xaml", UriKind.Relative));  
    cutomTheme.IsApplicationTheme = true

    Using Theme class allows you to specify custom or predefined theme.

    Let me know if you need more information.


    Greetings,
    Hristo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Jamest
    Jamest avatar
    41 posts
    Member since:
    Apr 2007

    Posted 13 Mar 2009 Link to this post

    As soon as I add this line to my App Constructor I get the error below, any ideas? (Removing the line doesn't throw the error) I have every dll from the binaries referenced in my project. 

        Telerik.Windows.Controls.StyleManager.ApplicationTheme = Telerik.Windows.Controls.ThemeManager.FromName("Vista");

     

    public App()  
    {  
       this.Startup += this.Application_Startup;  
       this.Exit += this.Application_Exit;  
       this.UnhandledException += this.Application_UnhandledException;  
       Telerik.Windows.Controls.StyleManager.ApplicationTheme = Telerik.Windows.Controls.ThemeManager.FromName("Vista");  
       InitializeComponent();  
    }  
     

     

     


    System.Windows.Markup.XamlParseException occurred
      Message="AG_E_RUNTIME_MANAGED_UNKNOWN_ERROR [Line: 145 Position: 44]"
      LineNumber=145
      LinePosition=44
      StackTrace:
           at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
           at MyApp.Page.InitializeComponent()
           at MyApp.Page..ctor()
      InnerException:

    Thank you for your time,
             Ender

    Edit: Typo

  5. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 13 Mar 2009 Link to this post

    Hi Ender,

    Most probably you have unchecked "Enable Just My Code (Managed only)" in Visual Studio menu.
    Please check it if you don't want to see this error. It is in Tools->Options->Debugging->General->Enable Just My Code (Managed only).

    This errors are handled so your application will work.

    Sincerely yours,
    Hristo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Jamest
    Jamest avatar
    41 posts
    Member since:
    Apr 2007

    Posted 13 Mar 2009 Link to this post

    Thank you for your reply, unfortunately "Enable Just My Code (Managed only) was checked with the sub item "warn if no user code on launch". I had the futures assemblies running and then installed Q1. I just uninstalled both and reinstalled only the Q1 trial. I had the futures version running pretty well, and after installing Q1 I  have this template issue and none of the Rad controls will render in Expression Blend 2/or VS2008 preview. Yet I get no compiling errors. When control is run all the rad controls function as expected.
    Edit - purchased product opening support
  7. Eric Schoenholzer
    Eric Schoenholzer avatar
    138 posts
    Member since:
    Mar 2004

    Posted 16 Mar 2009 Link to this post

    You mention only 3 themes.

    What about the others included dll like "Telerik.Windows.Themes.Default_Green.dll" ?

    Are they not working?

    Thanks

    Eric

  8. Eric Schoenholzer
    Eric Schoenholzer avatar
    138 posts
    Member since:
    Mar 2004

    Posted 16 Mar 2009 Link to this post

    The theming doesn't work in my project.

    The StyleManager is set to "Vista".

    But when I add later dynamically a new panel with a RadChart inside, it is using the default theme (Black).

    Why it doesn't use "Vista" ?

    Eric

  9. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 16 Mar 2009 Link to this post

    Hello Eric,

    Only the Vista, Summer and the default Office_Black themes are provided. The other do not contain Styles for all of our controls (and in fact they contain color schemes for Summer theme so they should be actually called Summer_Red, Summer_Green, etc...).

    What are you using: StyleManager.Theme="Vista" or the static property StyleManager.ApplicationTheme?
    The first one set theme only to the control that you attach it.
    The second one change the global (application) theme so RadChart should be with the Vista theme.
    If you are using the second one can you send us a sample project demonstrating your scenario?
    Thanks.

    Regards,
    Hristo
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Eric Schoenholzer
    Eric Schoenholzer avatar
    138 posts
    Member since:
    Mar 2004

    Posted 16 Mar 2009 Link to this post

    Hi Hristo,

    I'm using:

            public App()  
            {  
                this.Startup += this.Application_Startup;  
                this.Exit += this.Application_Exit;  
                this.UnhandledException += this.Application_UnhandledException;  
     
                StyleManager.ApplicationTheme = ThemeManager.FromName("Vista");  
     
                InitializeComponent();  
            }  
     

    So I try to prepare a sample project.

    Thanks

    Eric

  11. Eric Schoenholzer
    Eric Schoenholzer avatar
    138 posts
    Member since:
    Mar 2004

    Posted 16 Mar 2009 Link to this post

    I have posted the project. Ticket ID 197943.

    Thanks
    Eric
  12. Simon
    Simon avatar
    1 posts
    Member since:
    Mar 2009

    Posted 17 Mar 2009 Link to this post

    Hello,

    where can I find the Summer-Theme, you wrote about?
    Or did you mean the "default_"-Themes?

    Simon
  13. Sir
    Sir avatar
    31 posts
    Member since:
    Mar 2008

    Posted 17 Mar 2009 Link to this post

    I have the same issue.
    I've never been able to get different themes to show based on multiple examples from telerik videos & web pages.
    Futures didn't work, and now Q1 2009 doesn't work.
     
    StyleManager.ApplicationTheme = ThemeManager.FromName("Vista");

    didn't work

    Theme cutomTheme = new Theme(new Uri("/Telerik.Windows.Themes.Default_Red;component/Themes/generic.xaml", UriKind.Relative));
    cutomTheme.IsApplicationTheme = true;
    didn't work

    <Grid.Resources>

    <telerik:Theme Source="/Telerik.Windows.Themes.Vista;component/themes/generic.xaml" x:Key="theme"></telerik:Theme>

    </Grid.Resources>

    didn't work

    One of these days I'm going to be blown away just by seeing it actually work for the first time.

  14. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 18 Mar 2009 Link to this post

    Hello Sir Real,

    Can you send us sample project demonstrating the problem you have.
    To apply Vista theme you have to add reference to Telerik.Windows.Themes.Vista assembly.
    Then in the Application constructor (before InitializeComponents method) set StyleManager.ApplicationTheme property like this:

    StyleManager.ApplicationTheme = ThemeManager.FromName("Vista"); 

    That's it. This works for Silverlight and WPF.

    All the best,
    Hristo
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  15. Nik
    Nik avatar
    14 posts
    Member since:
    Jan 2007

    Posted 18 Mar 2009 Link to this post

    Hi

    I am getting the AG_E_RUNTIME_MANAGED_UNKNOWN_ERROR [Line: 54 Position: 56]

    Even I am not using the Theme. I have set the same thing u have mentioned in the Tool->Option ....
    Still no luck.


    This error is really disturbing me. Please help me out its urgent.



  16. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 18 Mar 2009 Link to this post

    Hello Nik,

    Could you send us project where this error happens?
    Without project there is little we can do.

    Sincerely yours,
    Hristo
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  17. SL
    SL avatar
    6 posts
    Member since:
    Jan 2009

    Posted 18 Mar 2009 Link to this post

    Not able to get your exmaple to work with a custom theme for Q1 2009

    Theme cutomTheme = new Theme(new Uri("/MyCustomThemeAssembly;component/Themes/generic.xaml", UriKind.Relative));     
    cutomTheme.IsApplicationTheme = true;    
     

    All I did was take the Office_Black Source and modify the colors from Orange to our site colors of Green compiled it and renamed it to Telerik.Windows.Themes.CustomTheme.  Then referenced this in the SL.  Also I noticed the the Office_Black theme does not have  a generic.xaml but rather an Generil_SL.xaml.  So here is what my version looked like, please tell me what step I left out. 

    Theme cutomTheme = new Theme(new Uri("/Telerik.Windows.Themes.CustomTheme;component/Themes/Generic_SL.xaml", UriKind.Relative));        
    cutomTheme.IsApplicationTheme = true;       
        
     

    thanks for the help to get this working...
  18. Eric Schoenholzer
    Eric Schoenholzer avatar
    138 posts
    Member since:
    Mar 2004

    Posted 19 Mar 2009 Link to this post

    After the response from your support team, RadChart doesn't support the theming mechanism in Silverlight.

    You need to set the skin via code.

    this.radChart1.Skin = "Vista";  

    Eric
  19. Jamest
    Jamest avatar
    41 posts
    Member since:
    Apr 2007

    Posted 19 Mar 2009 Link to this post

    SL, I am curious about the resolution of your issue.
  20. Sir
    Sir avatar
    31 posts
    Member since:
    Mar 2008

    Posted 23 Mar 2009 Link to this post

    Hello Hristo, thanks.

    Here is the link to a zip file which is my entire project.
    Theme Test Project

    It is just a simple RadSilverlight Menu (I was following one of your training videos).
    I cannot get the menu's theme to change no matter what theme I throw at it.
    Right now, the theme changing code is commented out in App.xaml.cs

    I appreciate if you can take a look and let me know what I'm doing wrong.

    (It would also be great if you can find out why I cannot get the menu to show in the upper left corner of the browser.  Our company uses IE6 internally)

    Thanks,
    Ray
  21. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 24 Mar 2009 Link to this post

    Hi Sir,

    You are unable to change the themes because the WebApplication is not connected with the silverlight application thus changes made in silverlight will not reflect in the web app (no one will copy the xap file from silverlight to web ClientBin directory).

    To link both project you should right click on the web project -> Property pages -> Silverlight Application.

    Then hit Add button and choose Silverlight project (from the dropdown) and click Add button. This way you will connect the web application with the silverlight application and all xap file will be copied to the web application ClientBin directory.

    After that go to App.xaml.cs and uncomment the StyleManager line. And you will have vista theme.
    One recommendation: remove the unused assemblies like: Telerik.Windows.QuickStart and all Default_* Themes assemblies (they do not include styles for all controls).

    About not being able place RadPane in top left - the reason is that RadFrameContainer is actually a Grid panel. Grid panel have by default HorizontalAlignment and VerticalAlignment set to Stretch and is taking all available space. Then your pages (RadPage) has some Width set and this width is smaller then the Grid actual width. So the grid centers the pages. If you want to put them at top left position just set HorizontalAlignment="Left" and VerticalAlignment="Top" on every page.

    One small note: the ScriptManager is taking some place at the top. Surround it with div element like this to remove the space reserved for it:

    <div style="margin:0; padding:0">  
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnableHistory="true">  
        </asp:ScriptManager> 
    </div> 

    Let me know if you need more information.

    Regards,

    Hristo
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  22. Sir
    Sir avatar
    31 posts
    Member since:
    Mar 2008

    Posted 24 Mar 2009 Link to this post

    Hristo,

    That is so awesome, thank you!
    I did all your suggestions and everything is perfect.
    Again, thanks for your time, patience, & tips.

    Ray
  23. Maarten
    Maarten avatar
    5 posts
    Member since:
    Mar 2009

    Posted 26 Mar 2009 Link to this post

    Hello,

    I'm having a similar issue.
    I can set the vista theme, but I can't set a custom theme (eg. the theme from http://blogs.telerik.com/ValentinStoychev/Posts/08-11-19/Tweaking_the_Theme_colors_for_Telerik_Silverlight_Controls.aspx ).

    Setting the theme in xaml results in an error, setting it in code behind doesn't change a thing.

    You can download my solution file over here.

    Thanks in advance.

    Kind regards,


    Maarten Thoelen


  24. David
    David avatar
    57 posts
    Member since:
    Jan 2009

    Posted 29 Mar 2009 Link to this post

    Like Maarten, I can set the Vista theme, but I cannot set any other theme aside from Summer... In my references, I have included every single theme reference. If I do Office_Black, nothing. If I do Default_Black, nothing. If I do Default_Red, nothing. This seems a little flakey, and I'm not sure why.

    Also, is there more documentation to be found other than taking guesses at intellisence and http://www.telerik.com/help/silverlight/introduction.html? The videos are useful, but it seems you know something that we don't know everytime I watch them. The tools are great, but the reference material for Silverlight controls really seems to be lacking.

    It'd be great to have a list of properties/methods for each control and what they do--in plain English. These tools are probably great if you've been a .NET programmer for a while, but they're really tricky to figure out if you're jumping from another language over to the Microsoft side. More helpful resources would be great.
  25. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 30 Mar 2009 Link to this post

    Hi David,

    With the Q1 release we shipped only three themes: Vista, Summer and the default Office_Black.
    The Default_* should not be used because they are just color variations of Summer theme and they do not include styles for all of our controls.
    One other thing - if you want to use the Office_Black theme you don't need to add reference to the Office_Black assembly because this theme is the default one. Also, setting the Office_Black should be done like this:
    <UserControl x:Class="SilverlightApplication31.Page2" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
        xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
        Width="400" Height="300">  
        <UserControl.Resources> 
            <telerik:Theme Source="/Telerik.Windows.Controls;component/Themes/generic.xaml" 
                    x:Key="officeBlackTheme" /> 
        </UserControl.Resources> 
        <Grid x:Name="LayoutRoot" Background="White">  
            <RadioButton Content="I have Theme" VerticalAlignment="Center" telerik:StyleManager.Theme="{StaticResource officeBlackTheme}"/>  
            <RadioButton Content="NO Theme" VerticalAlignment="Center" Margin="0 35 0 0"/>  
        </Grid> 
    </UserControl> 

    As for the documentation - you are right. We will definitely improve it.
    Thank you for your feedback.

    Let us know if you need more help.

    Best wishes,

    Hristo
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  26. Vic
    Vic avatar
    40 posts
    Member since:
    Mar 2009

    Posted 30 Mar 2009 Link to this post

    Hello,

    This is regarding RadControls Q1 2009 and the use of the Vista theme

    Simply enough I added a reference to Telerik.Windows.Themes.Vista and added the following code to my app.xaml

     public App() 
            { 
                this.Startup += this.Application_Startup; 
                this.Exit += this.Application_Exit; 
                this.UnhandledException += this.Application_UnhandledException; 
     
                // Telerik Vista Theme (needs to be set before page is added to the RootVisual) 
                // http://www.telerik.com/community/forums/silverlight/general-discussions/apply-themes-on-radcontrols-q1-2009.aspx 
                StyleManager.ApplicationTheme = ThemeManager.FromName("Vista"); 
                 
                InitializeComponent(); 
            } 

    Whenrun the following exceptions occurred in succession:

    System.Windows.Markup.XamlParseException
    Invalid attribute value telerikEditor:RadEditor for property TargetType. [Line: 1 Position: 225]
    Invalid attribute value telerikInput:RadCalendar for property TargetType. [Line: 1 Position: 223]
    Invalid attribute value calendar:CalendarView for property TargetType. [Line: 1 Position: 228]
    Invalid attribute value player:PlaylistPresenter for property TargetType. [Line: 1 Position: 223]
    Invalid attribute value dock:PaneHeader for property TargetType. [Line: 1 Position: 225]
    Invalid attribute value Docking:RadPane for property TargetType. [Line: 1 Position: 220]
    AG_E_PARSER_BAD_TYPE [Line: 1 Position: 291]
    Invalid attribute value telerikChart:RadChart for property TargetType. [Line: 1 Position: 226]
    AG_E_PARSER_BAD_TYPE [Line: 1 Position: 292]
    Invalid attribute value telerikGauge:RadGauge for property TargetType. [Line: 1 Position: 223]
    Invalid attribute value grid:GridViewLoadingIndicator for property TargetType. [Line: 1 Position: 227]
    Invalid attribute value controls:RadGridView for property TargetType. [Line: 1 Position: 222]

    Ignoringall warrants success but was wondering what the cause is, right now I am onlyusing the RadTreeView and RadWindow.

    Anyhelp is appreciated.

    Thanks,
    Vic
  27. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 31 Mar 2009 Link to this post

    Hello Vic,

    If you check Enable Just My Code (Managed Only) in Tools->Options->Debugging you won't see this errors. The cause of this is that our assembly (Telerik.Windows.Themes.Vista) have styles for all controls (e.g. RadWindow, RadDocking, RadEditor, RadSlider). We parse this assembly resources and try to load this types. If the load succeeds then we load (parse) this style. If the load fail then an exception is raised (and this exception is catched - but if you uncheck this option that I mention in the beginning you will still see it) and we don't load this style.
    This is needed because we wanted to have single assembly including styles for all RadControls but you may not have references to all needed assemblies.
    For the next version we will improve the way of checking if one assembly is loaded (so even if you uncheck enable just my code you won't see exceptions).

    I hope this helps. Let me know if you need more information.

    Sincerely yours,
    Hristo
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  28. yjh
    yjh avatar
    67 posts
    Member since:
    Aug 2007

    Posted 17 Apr 2009 Link to this post

    How can I apply vista theme to radpanelbar if not call StyleManager.ApplicationTheme = ThemeManager.FromName("Vista");  in the Application constructor before InitializeComponent method ?
  29. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 20 Apr 2009 Link to this post

    Hello yjh,

    Check this help article:
    http://www.telerik.com/help/silverlight/applying-theme-to-stanard-controls.html

    Sincerely yours,
    Valentin.Stoychev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  30. yelong
    yelong avatar
    28 posts
    Member since:
    Aug 2006

    Posted 20 Apr 2009 Link to this post

    I'd like to know if we can still have the old Default_Black theme in this release.
  31. yjh
    yjh avatar
    67 posts
    Member since:
    Aug 2007

    Posted 20 Apr 2009 Link to this post

    Thanks.

    But Source="/Telerik.Windows.Controls;component/Themes/generic.xaml" doesn't indicate the theme name. If I want use Vista theme,how to do it ?
Back to Top
DevCraft banner