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

How I apply theme of the common WPF controls ?

2 Answers 213 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Massimiliano Sorce
Top achievements
Rank 1
Massimiliano Sorce asked on 19 Feb 2010, 01:25 PM

Hi everyone,

whit others component suite it is possible, example:

 
    <Style TargetType="ComboBox" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.ComboBoxKey}}" />  
    <Style TargetType="TextBox" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.TextBoxKey}}" />  
    <Style TargetType="PasswordBox" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.PasswordBoxKey}}" />  
    <Style TargetType="Button" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.ButtonKey}}" />  
    <Style TargetType="ToolTip" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.ToolTipKey}}" />  
    <Style TargetType="CheckBox" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.CheckBoxKey}}" />  
    <Style TargetType="RadioButton" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.RadioButtonKey}}" />  
    <Style TargetType="ContextMenu" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.ContextMenuKey}}" />  
    <Style TargetType="ScrollViewer" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.ScrollViewerKey}}" /> 


This is possible with the WPF Telerik's suite ?

Thanks,

Massimiliano.

2 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 24 Feb 2010, 04:24 PM
Hello Massimiliano Sorce,

Please find attached an example. If you have further  questions please do not hesitate to ask us.

I hope this will help you.

All the best,
Dimitrina
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.
0
Massimiliano Sorce
Top achievements
Rank 1
answered on 24 Feb 2010, 09:01 PM
Hi Dimitrina,

following your example, I created this simple xaml. This is exactly what I need.

 
<Window x:Class="WpfApplication2.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
    Title="MainWindow" Width="300" Height="200"
     
    <Window.Resources> 
        <Style TargetType="Button" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=Button}}" /> 
        <Style TargetType="ListBox" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=ListBox}}" /> 
        <Style TargetType="TextBox" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=TextBox}}" /> 
        <Style TargetType="CheckBox" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=CheckBox}}" /> 
        <Style TargetType="RadioButton" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=RadioButton}}" /> 
        <Style TargetType="ScrollBar" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=ScrollBar}}" /> 
        <Style TargetType="ScrollViewer" BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows7Theme, ElementType=ScrollViewer}}" /> 
    </Window.Resources> 
     
    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
        <Grid x:Name="LayoutRoot" Margin="2" MinHeight="200" MinWidth="300"
            <Grid.RowDefinitions> 
                <RowDefinition Height="Auto" /> 
                <RowDefinition Height="*" /> 
            </Grid.RowDefinitions> 
            <StackPanel Orientation="Horizontal"
                <TextBox Width="150" Margin="3,1" VerticalAlignment="Center" IsEnabled="{Binding ElementName=chkbox, Path=IsChecked}" /> 
                <Button Margin="3" VerticalAlignment="Center" Padding="6,1" IsEnabled="{Binding ElementName=chkbox, Path=IsChecked}">Add</Button> 
                <CheckBox x:Name="chkbox" IsChecked="True" Margin="10,1,3,1" VerticalAlignment="Center">Enable</CheckBox> 
            </StackPanel> 
            <ListBox Grid.Row="1" x:Name="lstview" IsEnabled="{Binding ElementName=chkbox, Path=IsChecked}" Margin="3,1"
                <ListBoxItem>Prova 1</ListBoxItem> 
                <ListBoxItem>Prova 2</ListBoxItem> 
            </ListBox> 
        </Grid> 
    </ScrollViewer> 
     
</Window>

Move this styles from the "Window.Resources" in a "Resource Dictionary" and it's OK. :D

Thanks a lot,

Massimiliano.

Tags
General Discussions
Asked by
Massimiliano Sorce
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Massimiliano Sorce
Top achievements
Rank 1
Share this question
or