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

Change theme(style??) programmatically

6 Answers 547 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Aeroth
Top achievements
Rank 1
Aeroth asked on 08 Aug 2011, 07:23 AM
Hi Telerik Team,
How can I change RadWinow theme (style??) programmatically?
I've created a new class(not xaml file) that inherits from RadWindow and I'd like to change foreground and background of the Header, and the style of Minimize, Maximize, Close (X) buttons when my custom window instantiated.
As your demo example, the Header foreground is white and background is blue.

Where can I get all default themes list? 

Please help me out , thanks!

Regards,
Aeroth Lin

6 Answers, 1 is accepted

Sort by
0
Dani
Telerik team
answered on 08 Aug 2011, 09:33 AM
Hi Aeroth,

RadControls ship with nine ready-to-use themes. You can use them to customize the appearance of the RadWindow control. The one you are referring to and the one that is used thoughout our online demos is the Metro theme. Other themes include: Office Black, Office Blue, Office SIlver, Vista, Summer, Windows7, Transparent, Expression Dark. You can check all of them in the theming example of RadWidnow.

So to force your instance of RadWindow to have the look and feel of any of the themes, you should apply a theme to it. In XAML:
<telerik:RadWindow telerik:StyleManager.Theme="Metro" />

In code-behind:
StyleManager.SetTheme(myWindow, new MetroTheme());

Or set an application theme:
StyleManager.ApplicationTheme = new MetroTheme();

If you choose to have one of the themes , but wish to apply additional changes to the look & feel, you should make customizations upon the XAML for that particular theme.

I hope this helps.

Kind regards,
Dani
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Aeroth
Top achievements
Rank 1
answered on 09 Aug 2011, 02:49 AM
Hi Dani,
Thanks for the reply. I added a reference to Telerik.Windows.Themes.Office_Blue.dll and set the theme to Office_BlueTheme but it does not work. Did I miss anything?
StyleManager.SetTheme(this, new Office_BlueTheme());
Regards,
Aeroth Lin
0
Accepted
Dani
Telerik team
answered on 09 Aug 2011, 12:08 PM
Hello Aeroth,

You have to make sure that you add this line before InitializeComponent(). Attached is a working sample. It contains a RadWindow both as a separate UserControl and as an element inside the MainPage UserControl.

I hope this helps.

Kind regards,
Dani
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Aeroth
Top achievements
Rank 1
answered on 10 Aug 2011, 03:44 AM
Hi Dani,

The attached sample works. Unfortunately mine does not =.=, I don't know where's going wrong.
Please check this for me:

MyRadWindow.xaml
<navigation:RadWindow x:Class="MySilverlight.Controls.MyRadWindow"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480">
    <Grid x:Name="LayoutRoot">
 
    </Grid>
</navigation:RadWindow>

MyRadWindow.xaml.cs
public partial class MyRadWindow : RadWindow
    {
        #region Constructor
        public MyRadWindow()
        {
            StyleManager.SetTheme(this, new Office_BlueTheme());
            InitializeComponent();
             
            Grid grid = new Grid();
            grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(10, GridUnitType.Star) });
            TextBox content = new TextBox()
            {
                IsReadOnly = true,
                Background = new SolidColorBrush(Colors.White),
                TextWrapping = TextWrapping.Wrap,
                FontSize = 13F
            };
            Grid.SetRow(content, 0);
            Grid.SetColumn(content, 0);
            grid.Children.Add(content);
            base.Content = grid;
            base.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen;
            base.Width = 500;
            base.Height = 100;
        }
        #endregion
    }


Regards,
Aeroth Lin
0
Ivo
Telerik team
answered on 11 Aug 2011, 03:27 PM
Hi Aeroth,

We tested your code and it worked perfectly fine on our side. I have also attached working sample project that is using your code.

If you have any further problems could you please send us back a sample not working project?

Kind regards,
Ivo
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Aeroth
Top achievements
Rank 1
answered on 12 Aug 2011, 03:03 AM
Hi Ivo,

It works perfectly now, I frogot to add Assembly reference to my addin file.
<Assembly name="Telerik.Windows.Themes.Office_Blue.dll" checksum="f00" />
Thanks for the great help.

Regards,
Aeroth Lin
Tags
Window
Asked by
Aeroth
Top achievements
Rank 1
Answers by
Dani
Telerik team
Aeroth
Top achievements
Rank 1
Ivo
Telerik team
Share this question
or