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

Creating New Themes

7 Answers 99 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Simeon
Top achievements
Rank 1
Simeon asked on 08 Jan 2010, 12:34 PM
Hi,

We are trying to create our own theme assemblies to allow us to create themes in our customers coparate colours.  The way I figured it we could create a customer specific assembly and only download that resource for the correct customer.  I have started by taking the windows7 example solution and trying to change some of the brush resources.  When any of the theme projects compile they give warnings about a Media3d assembly not being found.  So I removed them and then the projects compile.  I then added a reference to the amended Windows7 theme dll and tried to set the application theme.  However when I do this I get a COM exception. 

So I was looking for some guidance on creating custom theme's as the documention is somewhat sparse.  Ideally we are looking to create OfficeRed, OfficeGreen, OfficeRoyalBlue that sort of thing for our customers.

We are on the 2009 Q3 Sp1 build 2009.3.1208.1030.   On a side note when we build the themes assemblies the get  a verion number of 0.0.0.0 could this be a cause of the problem?

Cheers

7 Answers, 1 is accepted

Sort by
0
Simon Störmer
Top achievements
Rank 1
answered on 12 Jan 2010, 08:17 AM

Hi James,

I am new to the Telerik Controls as well. But I am trying to create my own Theme as well, and I would like to share my results, perhaps they can help you. I looked at the Telerik themes and the way they are made up. I tried the following way and it worked so far:

1. Create a Silverlight class lib Assmebly that contains only of the XAML files. One .XAML file for each control and one Generic.xaml that references to the style files as merged dictionaries.

2. Within the "main" Silverlight project, create a class MyTheme that derives from theme. In the consturctor set the base classes Source-Property the a uri pointing to your Theme assemblys generic.xaml file.

3. Within the App.xaml.cs of the "main" Silverlight project, set an instance of MyTheme class as ApplicationTheme. This must be done as early as possible (I did it wihtin the constructor) in order to take effect.

I have a sample project I can send you, but I don't know how to upload it here. If you are interested, tell me your Email-Address and I will send it to you.

My own question, that I posted on http://www.telerik.com/community/forums/silverlight/general-discussions/create-a-custom-theme-based-on-exisiting-one.aspx goes a little further: how can I create my custom style based on an exisiting style? So that it uses for example office blue for all controls expect the ones I explicitly define otherwise. Any ideas on this will be appreciated.

Greetings,

Tobias.

 

0
Simeon
Top achievements
Rank 1
answered on 12 Jan 2010, 09:17 AM
Hi Tobias,

I read your post before I posted my thread.  If I am reading the help file correctly I think we have to create our styles as an actual theme resource dll and change the colours on the controls you are intrested in.  That is what we are trying to do really.  I have opened the theme solution that is installed as part of Telerik controls for silverlight and taken a copy of the office blue one and changed all of the resources to use a red gradient.  This theme compiles as a new assembly and can be accessed in the code behind when referenced but when I set the application theme to the new one I get a COM exception now.

I'll wait a few days to see if anyone replies here before opening a support ticket.

Cheers,
0
Dimitrina
Telerik team
answered on 14 Jan 2010, 07:48 AM
Hello James Nelson,

Please, accept our apologies for the late reply. In the attached file you can find a project containing the office_blue theme for all our controls. In case you want to customize some other theme you can find its project in the "Theme" folder under your installation folder. Should you have any further questions, please, do not hesitate to write us.

Best wishes,
Dimitrina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Simeon
Top achievements
Rank 1
answered on 14 Jan 2010, 09:16 AM
Hi Dimitrina,

Sorry I think you have misunderstood what we are trying to acheive.  I am not trying to customize a theme,  I am trying to add a brand new theme (I am using only using a supplied telerik theme as a basis).  So where in a application you would add a reference to Telerik.Windows.Themes.Windows7.dll and then in my application I would use a bit of code like

Telerik.Windows.Controls.

StyleManager.ApplicationTheme = new Windows7Theme();

 


to set my application theme to be windows7.  I want to do the same thing using my assembly and custom theme type. 

Cheers,

Jim.   
0
Dimitrina
Telerik team
answered on 14 Jan 2010, 11:35 AM
Hello James Nelson,

I believe that the application I attached to my previous mail shows the needed approach, but in XAML. Therefore, this time I attached a sample app, where I set the new theme in the codebehind, like:

public MainPage()
        {
            StyleManager.ApplicationTheme = new Windows7Theme();
            InitializeComponent();
        }

I hope this will get you started.

Kind regards,
Dimitrina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Simeon
Top achievements
Rank 1
answered on 15 Jan 2010, 09:19 AM
Sorry maybee I did not explain it correctly. 

What we are trying to achieve is a brand new theme assembly Mandata.Windows.Themes.OfficeRed.dll.  So I haved followed the help file and inherited the telerik theme class and have all of the xaml that you would use in your windows7 theme.  But, when I try to set it as the application theme I get a COM exception.  So I suppose what I was looking for was a solution that kind of did this as and brand new theme that is not included in Telerik.Windows.Controls.dll.

Cheers,
0
Dimitrina
Telerik team
answered on 21 Jan 2010, 01:19 PM
Hi James Nelson,

Please, accept our apologies for the late reply. In the below link you can find how to create a new theme:

http://www.telerik.com/community/forums/silverlight/radcontrols-for-silverlight-3-official/create-custom-theme-dll-for-q3-2009.aspx#1007817

As for the Telerik.Windows.Controls assembly - you will have to always refer it as it contains other important classes that are used by the rest of the controls and this assembly also contains the theming mechanism itself.

If you have further questions please do not hesitate to ask us.

I hope this will help you.

Sincerely yours,
Dimitrina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Simeon
Top achievements
Rank 1
Answers by
Simon Störmer
Top achievements
Rank 1
Simeon
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or