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

Set theme color into SolidColorBrush resource

3 Answers 1937 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kamran
Top achievements
Rank 3
Iron
Iron
Veteran
Kamran asked on 05 Nov 2018, 06:05 PM

I am trying to set theme (Fluent) AlternativeBrush into SolidColorBrush resource. I am facing error #FFF2F2F2' is not a valid value for property 'Color'. 

Everything is working fine, but problem when I want to define SolidColorBrush resource from theme. This resource will be used in other templates.

For reference following is sample code what I am doing now

 

<SolidColorBrush Color="{telerik:FluentResource ResourceKey=AlternativeBrush}" x:Key="AlternativeBrush"/>

3 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 07 Nov 2018, 12:14 PM
Hello Kamran,

Thank you for the provided code snippet. 

First, please allow me to say that you do not have to define a separate brush in order to use this resource. For example you can just use it like so:
<Border Background="{telerik:FluentResource ResourceKey=AlternativeBrush}" Width="100" Height="100" />

That said, it is not possible do define the brush in xaml, however you can define it in code like so:
var brush = new SolidColorBrush(Telerik.Windows.Controls.FluentPalette.Palette.AlternativeColor);

and later add it to the Resources collection of your application/window. 

Hope this helps.

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
1
Kamran
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 08 Nov 2018, 04:13 AM

Thank you Vladimir Stoyanov's for your response. I am following the same practices as you suggested. So whenever I define style/ template in resource I set background by telerik:Resource. But I have scenario where I don't want to define style for each item. For example in my case for some specific ellipse and rectangle i use fill/ stroke color to be from current theme.

finally I got some snippet from implicit theme styles. Please suggest me if I am doing wrong. but it works fine for me. Here is example

    <SolidColorBrush x:Key="BasicSolidColorBrush" Color="{Binding Source={x:Static telerik:FluentPalette.Palette}, Path=BasicSolidColor}"/>
 
 
<Grid Grid.Column="0" Background="{DynamicResource BasicSolidColorBrush}" >
.......
</Grid>

 

 

0
Accepted
Vladimir Stoyanov
Telerik team
answered on 08 Nov 2018, 02:15 PM
Hello Kamran,

Thank you for the additional information.

Indeed I have missed that you can also define the brush in xaml in the way that you have done. Your current approach is fine and if you find it suitable, you can continue using it.

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
Kamran
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Vladimir Stoyanov
Telerik team
Kamran
Top achievements
Rank 3
Iron
Iron
Veteran
Share this question
or