How to use Brush from current theme

10 posts, 1 answers
  1. Jaroslav Půbal
    Jaroslav Půbal avatar
    52 posts
    Member since:
    Dec 2009

    Posted 23 Apr 2010 Link to this post

    We have simple app with "Ribbon" above and "Grid" below.
    This app can change theme. So the Ribbon colors is changing.

    But Grid Backgroung is always white.
    Now we found this solution:


            <telerikRibbonBar:RadRibbonBar x:Name="Ribbon" />
            <StackPanel>
                <Grid  Background="{Binding Background, ElementName=Ribbon}">
                        <Controls3:RadButton Content="Button text" />
                    </Grid>
            </StackPanel>


    Is there better solution? Is it possible reference theme brush without have any Telerik components on the form (user control).
  2. Answer
    Pana
    Admin
    Pana avatar
    748 posts

    Posted 28 Apr 2010 Link to this post

    Hi Jaroslav Půbal,

    When you set StyleManager.Theme on a Control in Silverlight the StyleManagers finds a Style in the Theme ResourceDictionaries that can be applied on the Control and sets the Control's Style property. It is not possible to go there and search for a specific Key or otherwise use StaticResource to reference resource in the Themes.

    Eventually you can get our theme projects and add styles in them for your custom ContentControl that you can use as Border and the Theme for it will just change the Background and BorderBrush. This will be overkill though if all you need is to set a brush depending on the selected theme.

    Sincerely yours,
    Panayot
    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.
  3. Alexey Oyun
    Alexey Oyun avatar
    74 posts
    Member since:
    Mar 2010

    Posted 21 Jul 2010 Link to this post

    Is there better way to get to base theme colors. Like in winforms you can get system colors.
    May be it is possible to add property theme colors.
  4. Pana
    Admin
    Pana avatar
    748 posts

    Posted 23 Jul 2010 Link to this post

    Hi Alexey Oyun,

    There is no easy way to access these colors. Eventually you can open the control's assembly with reflector and pick the brushes from its generic xaml for office_black. For the rest of the themes you can do the same with the theme assemblies. Eventually you can even merge one of those dictionaries in your app.xaml and reference the brushes as StaticResource but I haven't tried it yet. In that case you may get the styles from these resource dictionaries applied to all your controls since SL4 introduced Implicit Styling.

    Greetings,
    Panayot
    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
  5. Alexey Oyun
    Alexey Oyun avatar
    74 posts
    Member since:
    Mar 2010

    Posted 23 Jul 2010 Link to this post

    Thank you for replay, I will try your suggested way.

    Thanks, Alexey.
  6. Pana
    Admin
    Pana avatar
    748 posts

    Posted 23 Jul 2010 Link to this post

    Hi Alexey Oyun,

    If you have problems or need somewhat resources do not hesitate to contact us again.

    Regards,
    Panayot
    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
  7. Heidi
    Heidi avatar
    6 posts
    Member since:
    Mar 2011

    Posted 03 Jun 2011 Link to this post

    Hello,
    In fact, I have the same question as described above. My application has a Ribbon on top, and below it, 2 regions with a menu bar and a content. I'd like to have these regions to inherit the background color of the Ribbon.
    When themes are switched, (which can happen in our future apps) , the background should switch along. Therefore I would not like to define it separately.

    I tried the example in the first post, but my application does not agree that there is a 'background' in the control 'telerik:RadRibbonBar'.

    Is there nowadays a better solution to keep this dynamic, and still use telerik keyed colors?
  8. Pana
    Admin
    Pana avatar
    748 posts

    Posted 08 Jun 2011 Link to this post

    Hello Heidi,

    Our theming mechanism does not support well such behavior. You will have to set Background to your user controls in code behind.

    Best wishes,
    Pana
    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
  9. Heidi
    Heidi avatar
    6 posts
    Member since:
    Mar 2011

    Posted 30 Jun 2011 Link to this post

    Too bad it isn't supported! Will it be, in the future?

    Isn't there some construction that an extra dictionary can reference to keys in the theme dll's of Telerik?
  10. Pana
    Admin
    Pana avatar
    748 posts

    Posted 07 Jul 2011 Link to this post

    Hi Heidi,

    We are researching such methods. In WPF you could use DynamicResource but Silverlight does not support them yet. We are waiting the release of SL5 to check upon the new features and will try to figure it out. For now the only feasible way would be to create a home brew Background setting mechanism.

    Greetings,
    Pana
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top