Hi,
I have in my App a RadScheduleView. Its theme is set to Windows8Theme in xaml :
I have in my App a RadScheduleView. Its theme is set to Windows8Theme in xaml :
<
telerik:RadScheduleView
x:Name
=
"ScheduleView"
MinTimeRulerExtent
=
"400"
MaxTimeRulerExtent
=
"1920"
AppointmentNavigationButtonsVisibility
=
"Never"
ToolTipTemplate
=
"{StaticResource AppointmentToolTipTemplate}"
telerik:StyleManager.Theme
=
"Windows8"
GroupHeaderContentTemplateSelector
=
"{StaticResource GroupHeaderContentTemplateSelector}"
/>
this theme is definitive, but I would like to be able to change the theme's AccentColor at runtime, so I wrote a method to do this:
public
static
void
ChangeTheme(ColorTheme theme)
{
var app = (App)Application.Current;
if
(theme == app.CurrentTheme)
return
;
app.Resources.MergedDictionaries.Clear();
AddResourceDictionary(
"resources/Common.xaml"
);
AddResourceDictionary(
"resources/GeneralResources.xaml"
);
AddResourceDictionary(
"resources/MenuResources.xaml"
);
AddResourceDictionary(
"resources/DataGridResources.xaml"
);
AddResourceDictionary(
"resources/DatePickerResources.xaml"
);
app.CurrentTheme = theme;
try
{ AddResourceDictionary(
string
.Format(CultureInfo.InvariantCulture,
"themes/{0}.xaml"
, theme)); }
catch
{ AddResourceDictionary(
"themes/Default.xaml"
); }
Windows8Palette.Palette.AccentColor = (Color)Application.Current.Resources[
"ThemeColor"
];
// pour le calendrier
}
private
static
void
AddResourceDictionary(
string
source)
{
var resourceDictionary = Application.LoadComponent(
new
Uri(source, UriKind.Relative))
as
ResourceDictionary;
Application.Current.Resources.MergedDictionaries.Add(resourceDictionary);
}
My issue is quite simple: the ScheduleView's color is always exactly one color late. i.e.:
let's say I have 3 theme colors : green, red, blue. Blue is the color at the beginning. I call the method to set the color to red, it stays blue. I call the method to set green, it becomes red, I call the color to set blue again, it becomes green, and so on...
can anybody tell me what I am doing wrong? I am at a complete lost as to how on earth this behaviour is possible...
Edit: I forgot a potentially usefull piece of information: this used to work with earlier versions of the telerik libraries (Q3 2012 as far as I remember). At the time, I used Windows8Colors.PaletteInstance, though, as it was not yet flagged as Obsolete.
9 Answers, 1 is accepted
0

Douw
Top achievements
Rank 1
answered on 22 Aug 2013, 04:43 AM
I have the same issue. Please help.
0
Hi,
It is not a good idea to use both StyleManager and merged resources. I suggest you to use our Implicit Styles and NoXaml binaries as described here. This way everything should work fine. You may also find additional information how to use Windows8 resources here.
Hope this helps.
Regards,
Rosen Vladimirov
Telerik
It is not a good idea to use both StyleManager and merged resources. I suggest you to use our Implicit Styles and NoXaml binaries as described here. This way everything should work fine. You may also find additional information how to use Windows8 resources here.
Hope this helps.
Regards,
Rosen Vladimirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Michel
Top achievements
Rank 1
answered on 27 Aug 2013, 07:47 AM
hi Rosen,
I did not understand the reference to StyleManager. As far as I can see, I am not using any StyleManager (or is it implicitly used when I'm trying to affect the value of he brush ?), and I am actually not using any merged resources as far as telerik themes are concerned.
I should have specified that the "themes" in the code only refer to some themes of mine (just brushes, actually, and a couple of styles I'm not using in this part of the app), not to telerik themes. I am only using telerik's Windows8 theme throughout my whole app, and am only trying to change the AccentColor of this theme at runtime. And this is where I'm at a loss.
I've also put together a small test app to try it :
xaml :
and the .cs :
nothing fancy here : just a RadSlider with Windows8Theme, and I'd like to change the AccentColor of the Theme at runtime. So this should reflect on the radSlider, except it doesn't.
So how should I do this ?
I did not understand the reference to StyleManager. As far as I can see, I am not using any StyleManager (or is it implicitly used when I'm trying to affect the value of he brush ?), and I am actually not using any merged resources as far as telerik themes are concerned.
I should have specified that the "themes" in the code only refer to some themes of mine (just brushes, actually, and a couple of styles I'm not using in this part of the app), not to telerik themes. I am only using telerik's Windows8 theme throughout my whole app, and am only trying to change the AccentColor of this theme at runtime. And this is where I'm at a loss.
I've also put together a small test app to try it :
xaml :
<
Window
x:Class
=
"tests.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Title
=
"test"
Height
=
"700"
Width
=
"330"
Background
=
"White"
>
<
Grid
HorizontalAlignment
=
"Stretch"
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
telerik:RadSlider
Name
=
"ZoomSlider"
HorizontalAlignment
=
"Center"
Width
=
"200"
Height
=
"20"
LargeChange
=
"100"
telerik:StyleManager.Theme
=
"Windows8"
/>
<
Button
Click
=
"Button_Click"
Content
=
"plop"
Grid.Row
=
"1"
Width
=
"200"
Height
=
"30"
HorizontalAlignment
=
"Center"
/>
</
Grid
>
</
Window
>
and the .cs :
using
System.Windows;
using
System.Windows.Media;
using
Telerik.Windows.Controls;
namespace
tests
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
public
partial
class
MainWindow : Window
{
int
i;
public
MainWindow()
{
InitializeComponent();
}
private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
switch
(i % 7)
{
case
0: Windows8Palette.Palette.AccentColor = Colors.Red;
break
;
case
1: Windows8Palette.Palette.AccentColor = Colors.Orange;
break
;
case
2: Windows8Palette.Palette.AccentColor = Colors.Yellow;
break
;
case
3: Windows8Palette.Palette.AccentColor = Colors.Green;
break
;
case
4: Windows8Palette.Palette.AccentColor = Colors.Blue;
break
;
case
5: Windows8Palette.Palette.AccentColor = Colors.Indigo;
break
;
case
6: Windows8Palette.Palette.AccentColor = Colors.Violet;
break
;
}
i++;
}
}
}
nothing fancy here : just a RadSlider with Windows8Theme, and I'd like to change the AccentColor of the Theme at runtime. So this should reflect on the radSlider, except it doesn't.
So how should I do this ?
0
Hello Thierry,
In order to achieve this you have to use our NoXAML binaries and merge the resources in App.xaml. I've prepared a sample project for you to demonstrate this behavior. Please check it and inform us in case you have any other problems or concerns.
Regards,
Rosen Vladimirov
Telerik
In order to achieve this you have to use our NoXAML binaries and merge the resources in App.xaml. I've prepared a sample project for you to demonstrate this behavior. Please check it and inform us in case you have any other problems or concerns.
Regards,
Rosen Vladimirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Michel
Top achievements
Rank 1
answered on 30 Aug 2013, 12:52 PM
Hi Rosen,
I ran your test project, and it works, but it is not quite relevant with my issue. Indeed, what you do in the project works in mine as well and is not quite what I'm trying to achieve.
What You do:
<telerik:RadSlider Name="ZoomSlider" Background="{telerik:Windows8Resource ResourceKey=MarkerBrush}" />
What I do:
<telerik:RadSlider Name="ZoomSlider" telerik:StyleManager.Theme="Windows8" />
I do this because I want the whole theme for the expander, not just the background's color
I also do:
<telerik:RadScheduleView x:Name="ScheduleView" telerik:StyleManager.Theme="Windows8" >
and then, I would like to be able to change the AccentColor of the windows8 theme so that all controls with the Windows8 theme applied get the new AccentColor.
and THIS is what does not work.
If I bind directly to the windows8 theme's AccentColor for, say, a background, then it works, But I cannot bind all the brushes using this color in the Scheduleview as it would mean redoing the whole template (I don't have access to those properties from the Scheduleview directly)
plus, I cannot merge the themes dictionnaries like you do, as I only want the windows8 theme for specific controls (scheduleview and expander dor instance), but not all.
any other idea ?
I ran your test project, and it works, but it is not quite relevant with my issue. Indeed, what you do in the project works in mine as well and is not quite what I'm trying to achieve.
What You do:
<telerik:RadSlider Name="ZoomSlider" Background="{telerik:Windows8Resource ResourceKey=MarkerBrush}" />
What I do:
<telerik:RadSlider Name="ZoomSlider" telerik:StyleManager.Theme="Windows8" />
I do this because I want the whole theme for the expander, not just the background's color
I also do:
<telerik:RadScheduleView x:Name="ScheduleView" telerik:StyleManager.Theme="Windows8" >
and then, I would like to be able to change the AccentColor of the windows8 theme so that all controls with the Windows8 theme applied get the new AccentColor.
and THIS is what does not work.
If I bind directly to the windows8 theme's AccentColor for, say, a background, then it works, But I cannot bind all the brushes using this color in the Scheduleview as it would mean redoing the whole template (I don't have access to those properties from the Scheduleview directly)
plus, I cannot merge the themes dictionnaries like you do, as I only want the windows8 theme for specific controls (scheduleview and expander dor instance), but not all.
any other idea ?
0

Douw
Top achievements
Rank 1
answered on 30 Aug 2013, 10:47 PM
Hi Rosen,
I agree with Thierry, we need a function that change the Accent colour for everything that uses the W8 theme.
I expect this code to work:
Regards,
Douw
I agree with Thierry, we need a function that change the Accent colour for everything that uses the W8 theme.
I expect this code to work:
Windows8Palette.Palette.AccentColor = _primaryColour;
Regards,
Douw
0
Accepted
Hello,
The code you have mentioned will work with XAML assemblies only when you merge Windows8ResourceDictionary in your App.xaml:
You can check attached project for a reference how to achieve this. When you click the button, the AccentColor will be changed.
Hopefully this helps.
Regards,
Rosen Vladimirov
Telerik
The code you have mentioned will work with XAML assemblies only when you merge Windows8ResourceDictionary in your App.xaml:
<
ResourceDictionary
>
<
ResourceDictionary.MergedDictionaries
>
<
telerik:Windows8ResourceDictionary
/>
</
ResourceDictionary.MergedDictionaries
>
</
ResourceDictionary
>
You can check attached project for a reference how to achieve this. When you click the button, the AccentColor will be changed.
Hopefully this helps.
Regards,
Rosen Vladimirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Michel
Top achievements
Rank 1
answered on 31 Oct 2013, 02:39 PM
better late than never :
I tried your last suggestion and it works like a charm, (though I still don't understand why and how).
thanks a lot, Rosen
I tried your last suggestion and it works like a charm, (though I still don't understand why and how).
thanks a lot, Rosen
0
Hello Thierry,
I'm glad you have found the solution useful. Feel free to contact us in case you have any other problems or concerns.
Regards,
Rosen Vladimirov
Telerik
I'm glad you have found the solution useful. Feel free to contact us in case you have any other problems or concerns.
Regards,
Rosen Vladimirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>