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

Reusing Theme Elements in UserControl

4 Answers 76 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Phillip Hamlyn
Top achievements
Rank 1
Phillip Hamlyn asked on 06 May 2010, 08:58 PM
Hi,

I have a series of user controls which contain a mixture of MS and Telerik controls. I want to set my UserControl background to the Background that is set on Telerik controls such as ribbon bar and tab strip so they share the same basic coloration. I can't figure out how to isolate and set my Background to the same resource as is used in a selected Telerik control.

Can you help ?

Phillip

4 Answers, 1 is accepted

Sort by
0
Jim Daly
Top achievements
Rank 1
answered on 07 May 2010, 07:41 PM
I don't think there is any way to access the same Brush that the RibbonBar uses, but if you could figure out the hex value of the RibbonBar background color in some image tool like Photoshop, you could create a Brush with that same RGB value and set the backround of the top-level container in your UserControl to that brush...like <Grid Background="{StaticResource MyBackgroundBrush}">.

Say the background is black, your brush would look like this:

<SolidColorBrush x:Key="MyBackgroundBrush" Color="#FF000000"/>
0
Phillip Hamlyn
Top achievements
Rank 1
answered on 07 May 2010, 08:10 PM
Thanks for the suggestion, the only problem with this approach is the ability of the user to change colors.

It did suggest another approach however, which I will try and then report back, and thats to simply copy the background brush of the ribbon bar as I find it at runtime through code ; i.e.

this.Background = mainMenu.radRibbonBar.Background

I wonder if this will work ...

Phillip
0
Phillip Hamlyn
Top achievements
Rank 1
answered on 07 May 2010, 08:28 PM
Hmmm, to answer my own post, the RadRibbonBar.Background property is always null.

Any other ideas ?
0
Jim Daly
Top achievements
Rank 1
answered on 10 May 2010, 04:59 PM
Hmm, not sure if it would work, but you could try using element data binding. Something like this:

<Grid x:Name="LayoutRoot" Background="{Binding Background, ElementName=MyRadRibbonBar}">
...
</Grid>

Tags
General Discussions
Asked by
Phillip Hamlyn
Top achievements
Rank 1
Answers by
Jim Daly
Top achievements
Rank 1
Phillip Hamlyn
Top achievements
Rank 1
Share this question
or