Theming RadGridView through style

4 posts, 0 answers
  1. Ben
    Ben avatar
    1 posts
    Member since:
    Aug 2013

    Posted 13 Aug 2013 Link to this post

    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
  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 14 Aug 2013 Link to this post

    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 >>
  3. DevCraft banner
  4. srecov
    srecov avatar
    7 posts
    Member since:
    Jul 2013

    Posted 17 Aug 2013 Link to this post

    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

  5. srecov
    srecov avatar
    7 posts
    Member since:
    Jul 2013

    Posted 20 Aug 2013 Link to this post

    Hi, since I have encountered additional problems with rad controls, I havel fill a support ticket for this subject too.  
Back to Top