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

Theming RadGridView through style

3 Answers 83 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Iron
Ben asked on 13 Aug 2013, 03:31 PM
Hi

I am trying to apply a style to all RadGridView controls throughout my application. It sets a few properties, and applies the Windows8 theme.

However, the RadGridView control doesn't seem to work in quite the same way as the other Telerik controls I am using - I have applied the Windows8 theme to them as shown at item (1) in the code sample below. This, by itself, does not appear to affect the RadGridView. However, at this point, the other setters do take effect - ValidatesOnDataErrors behaves correctly.

In order to apply the theme, I resorted to item (2) - applying it via a setter - which correctly applies the theme. However, this appears to override the other setters - ValidatesOnDataErrors returns to default behaviour.

<Style
        x:Key="RadGridViewStyleBase"
        telerik:StyleManager.BasedOn="Windows8" <!-- (1): does not seem to have any effect -->
        TargetType="telerik:RadGridView">
        <Setter
            Property="AutoGenerateColumns"
            Value="False" />
        <Setter
            Property="BorderThickness"
            Value="0" />
        <Setter
            Property="BorderBrush"
            Value="Transparent" />
        <Setter
            Property="ScrollViewer.HorizontalScrollBarVisibility"
            Value="Auto" />
        <Setter
            Property="ScrollViewer.VerticalScrollBarVisibility"
            Value="Auto" />
        <Setter
            Property="RowIndicatorVisibility"
            Value="Collapsed" />
        <Setter
            Property="telerik:StyleManager.Theme" <!-- (2): appears to override all other setters -->
            Value="Windows8" />
         
        <Setter
            Property="ValidatesOnDataErrors"
            Value="InViewMode" />
    </Style>

My question, therefore, is this: how can I apply the Windows8 theme to the grid via the style, without preventing other properties from taking effect? Is this a bug, or am I missing something in my code?

Thanks
Ben

3 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 14 Aug 2013, 08:12 AM
Hello Ben,



Indeed the style is not applied in this scenario, when you are working with StyleManager. In order to avoid such discrepancies I strongly recommend you to use NoXAML binaries combined with implicit styles.
In our online documentation you will find more info on that matter, following this link. 




Regards,
Vanya Pavlova
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
srecov
Top achievements
Rank 1
answered on 17 Aug 2013, 09:38 AM
Hi
I am using implicit styles and have the following references:
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/System.Windows.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Data.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.GridView.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Input.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
 
            <ResourceDictionary Source="Assets/Styles.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

I have two questions:
1. When I put the following style in Assets/Styles.xaml, compile fails, but when I put in MainPage.xaml UserControl.Resources it works as expected. Why?
<Style  TargetType="telerik:RadGridView" BasedOn="{StaticResource RadGridViewStyle}">
    <Setter Property="RowHeight" Value="20" />
</Style>

2. Using the same style I get a VS2012 warning: Resource RadGridViewStyle is not found, however there is no copile or JustCode errors and application works. See attached picture

Best regards
Srečo

0
srecov
Top achievements
Rank 1
answered on 20 Aug 2013, 02:20 PM
Hi, since I have encountered additional problems with rad controls, I havel fill a support ticket for this subject too.  
Tags
GridView
Asked by
Ben
Top achievements
Rank 1
Iron
Answers by
Vanya Pavlova
Telerik team
srecov
Top achievements
Rank 1
Share this question
or