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

brushes

5 Answers 58 Views
Docking
This is a migrated thread and some comments may be shown as answers.
tomas
Top achievements
Rank 1
tomas asked on 26 Dec 2011, 08:12 PM
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

5 Answers, 1 is accepted

Sort by
0
Dani
Telerik team
answered on 27 Dec 2011, 09:42 AM
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 >>
0
tomas
Top achievements
Rank 1
answered on 28 Dec 2011, 05:31 PM
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
0
Dani
Telerik team
answered on 29 Dec 2011, 12:21 PM
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 >>
0
tomas
Top achievements
Rank 1
answered on 29 Dec 2011, 03:07 PM
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
0
Dani
Telerik team
answered on 03 Jan 2012, 03:36 PM
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 >>
Tags
Docking
Asked by
tomas
Top achievements
Rank 1
Answers by
Dani
Telerik team
tomas
Top achievements
Rank 1
Share this question
or