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

Issue with applying custome theme at runtime

9 Answers 144 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ganesh Jagdale
Top achievements
Rank 1
Ganesh Jagdale asked on 01 Mar 2010, 03:47 PM
Hi Telerik,

I saw ur example on this link http://www.telerik.com/community/forums/silverlight/radcontrols-for-silverlight-3-official/create-custom-theme-dll-for-q3-2009.aspx#1007817

Follows same instruction give in above link
   In custom theme project
   I had    create a class which inherit from Theme
    

public

 

class CustomeWindows7_Theme:Telerik.Windows.Controls.Theme

 

{

 

        public CustomeWindows7_Theme()

 

        {

            Source =

new Uri("/Themes/MyGeneric.xaml",UriKind.RelativeOrAbsolute);

 

        }

}


and it works.

It work when I write like this in .xaml file

<

 

customTheme:CustomeWindows7_Theme x:Key="Theme" Source="/TDG.Pulse.Theme.Windows7;Component/Themes/MyGeneric.xaml" IsApplicationTheme="True" />

 

Even when I specify Source file in above constructor I need to specify Source  property once again.
If I haven't specify then I got this error "AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 16 Position: 84]"

I don't understant why this comes up... why there is such  depedancy way for specifing source property in client

Even It is fine 
but my problem is I am not  able to apply theme at runtime like this

 

CustomeWindows7_Theme the = new CustomeWindows7_Theme();

 

 

the.Source = new Uri("/TDG.Pulse.Theme.Windows7;Component/Themes/MyGeneric.xaml", UriKind.RelativeOrAbsolute);

 

 

the.IsApplicationTheme = true;

 

 

Telerik.Windows.Controls.StyleManager.ApplicationTheme = the;

Telerik Default theme can be apply at runtime..
 Is there any mistake I made?
 
Pls help me out...

Thanks
Ganesh

 






 

9 Answers, 1 is accepted

Sort by
0
Ganesh Jagdale
Top achievements
Rank 1
answered on 02 Mar 2010, 09:52 AM
Hi telerik,

The above case happened only for silverlight controls. e.g Grid
I wrote Style for Grid also..
 That apply in xaml file but if we apply at runtime then theme is not  being  applied for Grid..

Why this wrong  going to happended ?
Even I test it for exapmle which given on this link http://www.telerik.com/community/forums/silverlight/radcontrols-for-silverlight-3-official/create-custom-theme-dll-for-q3-2009.aspx#1007817  attached File name is ::customewindows7theme.zip

same problem is there...
In that example theme applyed in .xaml page.
In that example I added stle for silverlight control "Grid"
Even I applyed theme ar  runtime then theme is applied olnly for telerik control not for silverlight control i.e for Grid

Why there is such deference beteen applying theme at design time for silverlight control and applying theme at runtime time for silverlight control.
I am very eager to see this answer...

Pls help me ...

Thanks ,
Ganesh

 
0
Hristo
Telerik team
answered on 04 Mar 2010, 07:10 AM
Hello Ganesh Jagdale,

I'm not sure that I understand your problem correctly. In the first post you have to specify the Source in XAML again because in code it is wrong - you have to specify the source using the ';component' syntax.
That is why it is not working if you don't change it in XAML.
From the second post I assume that you managed to apply Application theme. Now the question is which Grid do you refer - Microsoft DataGrid or Grid panel?
In Silverlight 3 you cannot apply global Styles for Panel classes so it won't work for Grid panel.
If you are talking about Microsoft DataGrid control - we don't provide theme for it, only of RadGridView.

Let me know if you need more information.

All the best,
Hristo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ganesh Jagdale
Top achievements
Rank 1
answered on 04 Mar 2010, 03:57 PM
Hi Hristo ,
  Thanks for reply..
  I write ';component'  syntax like this in custome theme class
 

Source =

new Uri("/Theme.Windows7;Component/Themes/MyGeneric.xaml", UriKind.RelativeOrAbsolute);

 

 

 

 

 


still it don't work,
is there any mistake in above statement?
if there,pls give me the proper sytax needed for that...


 And you said that, 
    In Silverlight 3 you cannot apply global Styles for Panel classes so it won't work for Grid panel.

But I write like this,
  <UserControl.Resources>

 

 

<customTheme:CustomeWindows7_Theme x:Key="Windows7Theme" Source="/TDG.Pulse.Theme.Windows7;Component/Themes/MyGeneric.xaml" IsApplicationTheme="True" />

 

 

 

</UserControl.Resources>

 

 

 

<Grid x:Name="LayoutRoot" telerik:StyleManager.Theme="{StaticResource Windows7Theme}">

 

 

 

</Grid>

Then style applied for Grid also which I wrote in custome theme project..

But When I applied at runtime, then It won't apply
CustomeWindows7_Theme the = new CustomeWindows7_Theme(); 
the.Source = new Uri("/TDG.Pulse.Theme.Windows7;Component/Themes/MyGeneric.xaml", UriKind.RelativeOrAbsolute); 
the.IsApplicationTheme = true; 
 So, Is there any other way needed to mention?
If u have any such  example  which applying custom theme at runtime for Grid Panel , pls share with me....

Pls help me out  ...

Thanks,
 Ganesh. 

0
Hristo
Telerik team
answered on 05 Mar 2010, 09:36 AM
Hi Ganesh Jagdale,

If this is working:
<customTheme:CustomeWindows7_Theme x:Key="Windows7Theme" Source="/TDG.Pulse.Theme.Windows7;Component/Themes/MyGeneric.xaml" IsApplicationTheme="True" /> 

then you should specify the same source in the theme constructor:
Source = new Uri("/TDG.Pulse.Theme.Windows7;Component/Themes/MyGeneric.xaml", UriKind.RelativeOrAbsolute);

Using this syntax is not Application theme but a specific theme so this is why it is working:
<Grid x:Name="LayoutRoot" telerik:StyleManager.Theme="{StaticResource Windows7Theme}">

If you don't set it like this - then it won't apply to Grid panel (like you noticed).

Also Application theme should be set in the Application constructor before InitializeComponent method (as early as possible) and changing application theme at runtime in not supported in Silverlight 3.

I hope this answer your questions.

Regards,
Hristo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ganesh Jagdale
Top achievements
Rank 1
answered on 05 Mar 2010, 03:55 PM
Hi Hristo ,

You are right... 
Thanks For replay

Thanks 
ganesh 
0
Sherry George
Top achievements
Rank 1
answered on 30 May 2010, 11:43 AM
Hi,

I want to know if changing themes dynamically without refreshing the page is possible with silverlight 4 controls??

thanks in advance
Sherry
0
Ganesh Jagdale
Top achievements
Rank 1
answered on 31 May 2010, 05:38 AM
Hi Sherry,
    I tried the same thing in Silverlight 3 but it's not posssible at all because we need to  update or  Refresh  RootVisual  again if we change theme dymanicaly. This can be possible if u set individualy style of each element
Even this will  not be  possible in silverlight 4. 

Thanks,
Ganesh
0
Sherry George
Top achievements
Rank 1
answered on 31 May 2010, 07:33 AM
Hi Ganesh,

Thanks for the reply. updating rootvisual also is not applying the theme for me.. I have to reload the entire page to apply a theme.... am I doing something wrong here?

Sherry
0
Yavor Georgiev
Telerik team
answered on 31 May 2010, 05:32 PM
Hi Sherry George,

 You have to bind the StyleManager.Theme attached property of every telerik control. Silverlight does not support changing the theme at runtime.

How do you trigger the refresh of your root visual?

Best wishes,
Yavor Georgiev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
Ganesh Jagdale
Top achievements
Rank 1
Answers by
Ganesh Jagdale
Top achievements
Rank 1
Hristo
Telerik team
Sherry George
Top achievements
Rank 1
Yavor Georgiev
Telerik team
Share this question
or