brushes

6 posts, 0 answers
  1. tomas
    tomas avatar
    139 posts
    Member since:
    Sep 2012

    Posted 26 Dec 2011 Link to this post

    Hi Telerik.

    I would like to enable the user to switch the themes on the fly. It is simple and it is working.

    I would like to use brushes of the Docking control to my own controls. How can i reference that brushes? I dont want to create my own themes nor modify your templates. They are really big and I dont want to have a problems with the next releases.

    Thank you very much.

    Tom

  2. Dani
    Admin
    Dani avatar
    848 posts

    Posted 27 Dec 2011 Link to this post

    Hi Tomas,

    Themes in RadControls for Silverlight are distributed in separate assemblies. For example, you will find a Metro project in your RadControls installation folder. You could include that project in your solution and reference any resource dictionary from it.

                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                 x:Class="SilverlightApplication1.App"
                 >
        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="/Metro;component/Themes/Metro/Docking.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Application.Resources>
    </Application>

    Then, you could reference a brush from the theme in other controls and UI elements. For example:
    <ComboBox Grid.Row="1" Foreground="{StaticResource AccentBrush}" Margin="20" VerticalAlignment="Center" Width="200">
                <ComboBoxItem Content="Item 1" />
                <ComboBoxItem Content="Item 2" />
                <ComboBoxItem Content="Item 3" />
                <ComboBoxItem Content="Item 4" />
            </ComboBox>

    I hope this helps.

    Regards,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. DevCraft banner
  4. tomas
    tomas avatar
    139 posts
    Member since:
    Sep 2012

    Posted 28 Dec 2011 Link to this post

    Hi Dani.

    Unfortunately this is too complicated.

    My users can switch themes.

    Something like

    myControl.myBrush = (Brush) myDockingControl.Resources["backgroundBrush"] ;

    would not work?

    It would always use the brush from a current theme...

    Thank you Tom
  5. Dani
    Admin
    Dani avatar
    848 posts

    Posted 29 Dec 2011 Link to this post

    Hi Tom,

    You cannot reference a resource from the RadDocking control in the that way. The suggested code would work if you had:
    <telerikDocking:RadDocking x:Name="docking" >
                <telerikDocking:RadDocking.Resources>
                    <SolidColorBrush x:Key="backgroundBrush" Color="Red" />
                </telerikDocking:RadDocking.Resources>
     ...            
    </telerikDocking:RadDocking>
    which would make that resource a part of the application resources. 

    At this point you will be able to do something like the following:
    this.myButton.Foreground = this.docking.Foreground;
    This is, of course, not of much use as usually you would have only a Foreground and a Background property to use, which are often times black by default.

    The bottomline is, you cannot reference resources unless you first include them or merge them in your project in some way.

    I hope this helps.

    Regards,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  6. tomas
    tomas avatar
    139 posts
    Member since:
    Sep 2012

    Posted 29 Dec 2011 Link to this post

    Hi Dani.

    IT is a shame.

    What exactly is doing that line StyleManager.ApplicationTheme = new Office_BlueTheme();  of code? App.xaml.cz:
    public App()
    {
        this.Startup += this.Application_Startup;
        this.Exit += this.Application_Exit;
        this.UnhandledException += this.Application_UnhandledException;
     
        StyleManager.ApplicationTheme = new Office_BlueTheme();
        InitializeComponent();
    }

    These resources cannot be used?

    I don't want to modify all my control resources when the user switches the theme. (to include the right theme to every user control)

    Thank you for your quick response.

    Tom
  7. Dani
    Admin
    Dani avatar
    848 posts

    Posted 03 Jan 2012 Link to this post

    Hello Tomas,

    As the syntax suggests, the line you posted sets an Application theme. Setting an application theme will apply that theme implicitly to each Telerik control. 

    As explained earlier, referencing and using a brush by Key  from an already compiled theme or control is not accomplishable unless you first copy this resource in your project.

    I am not sure I understand exactly what your scenario is and what you wish to achieve. Please, explain in more details so that we can give advice on possible approaches.

    Greetings,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top
DevCraft banner