Reusing Theme Elements in UserControl

5 posts, 0 answers
  1. Phillip Hamlyn
    Phillip Hamlyn avatar
    26 posts
    Member since:
    Jul 2009

    Posted 06 May 2010 Link to this post

    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
  2. Jim Daly
    Jim Daly avatar
    13 posts
    Member since:
    Apr 2010

    Posted 07 May 2010 Link to this post

    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"/>
  3. Phillip Hamlyn
    Phillip Hamlyn avatar
    26 posts
    Member since:
    Jul 2009

    Posted 07 May 2010 Link to this post

    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
  4. Phillip Hamlyn
    Phillip Hamlyn avatar
    26 posts
    Member since:
    Jul 2009

    Posted 07 May 2010 Link to this post

    Hmmm, to answer my own post, the RadRibbonBar.Background property is always null.

    Any other ideas ?
  5. Jim Daly
    Jim Daly avatar
    13 posts
    Member since:
    Apr 2010

    Posted 10 May 2010 Link to this post

    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>

Back to Top