Excluding a single control from chosen Theme

6 posts, 2 answers
  1. Russell
    Russell avatar
    4 posts
    Member since:
    Sep 2016

    Posted 05 Jul Link to this post

    Hello! I am using the Windows8 theme throughout my WPF application, however I would like to exclude a ListView from the styling. Is this possible? I have searched a bit and have looked at this guide:

     

    http://docs.telerik.com/devtools/wpf/styling-and-appearance/stylemanager/common-styling-themes-mscontrols

     

    But I am not sure if I am able to 'null' out a style and let it take on the default styling while still having all other elements use the theme of my choice. 

    Thank you!

    Regards,

    Joel

  2. Russell
    Russell avatar
    4 posts
    Member since:
    Sep 2016

    Posted 05 Jul in reply to Russell Link to this post

    Forgive my own follow up to this question but its related:

    Whenever I try to override a simple style rule such as HorizontalContentAlignment for a GridViewCell, the entire grid becomes blank, no data is visible at all. Why is this? Do I need to copy the entire style in Blend, change it to my liking, then bring over the modified style to override the chosen Telerik style?

    This approach is a little frustrating because your styles are beautiful, but confusing to customize unlike other standard WPF controls.

  3. Answer
    Sia
    Admin
    Sia avatar
    673 posts

    Posted 07 Jul Link to this post

    Hello Russel,

    It appears that you are setting the theme through StyleManager, is that true?

    By saying ListBox, do you mean the MS ListView control? If you are using XAML binaries and style the Telerik controls by setting StyleManager, you need to set telerik:StyleManager.Theme="Windows8" explicitly to the MS control in order to have our style applied to it.

    Also I have checked styling the GridViewCell:
    <Style TargetType="telerik:GridViewCell">
        <Setter Property="HorizontalContentAlignment" Value="Center" />
    </Style>

    and everything works on my end.

    However if you want to use implicit styling and our NoXAML binaries, then it is very important to base your custom styles on ours as follows:
    <Style TargetType="telerik:GridViewCell" BasedOn="{StaticResource GridViewCellStyle}">
        <Setter Property="HorizontalContentAlignment" Value="Center" />
    </Style>

    I hope this helps.

    Regards,
    Sia
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  4. Russell
    Russell avatar
    4 posts
    Member since:
    Sep 2016

    Posted 07 Jul in reply to Sia Link to this post

    Sia,

    Thanks for the help. I am using the default MS ListView control instead of the telerik:ListView for an explicit requirement. 

    I am using the XAML binaries and globally setting the theme in the App.xaml using the Windows8 theme everywhere. 

    When I inspect my ListView in the Live Property Explorer I notice the ListView is using Windows8Resource's. I have attached a screenshot of the property explorer. I was wondering how to exclude this default MS control from the theme I have in the binaries, if that's even possible. 

    Here is the code of my ListView:

    <ListView
        MinHeight="50"
        VerticalAlignment="Bottom"
        HorizontalContentAlignment="Stretch"
        AllowDrop="True"           
        ItemTemplate="{StaticResource PlayerTemplate}"
        ItemsSource="{Binding Players}">
    </ListView>

     

    The PlayerTemplate resource is really just a grid that organizes the data - it contains no styling other than margin, etc.

    Thank you for the snippet regarding the gridviewcell. I will give that another shot I may have just messed up reading the instructions.

    Thanks for the help. I hope the attached screenshot helps describe what I am trying to describe.

  5. Answer
    Sia
    Admin
    Sia avatar
    673 posts

    Posted 10 Jul Link to this post

    Hello again,

    We do not provide styles for the MS ListView control, only for the MS ListBox control.

    You said that you are using XAML binaries and set the theme in App.xaml which confuses me a little.

    By referencing XAML binaries you use control assemblies (like Telerik.Windows.Controls.dll) in which all needed XAML is included. Then our theming mechanism requires to set the theme on application level by setting in code-behind:
    StyleManager.ApplicationTheme = new Windows8Theme();
    or setting on control level:
    telerik:StyleManager.Theme="Windows8"

    If you want to use NoXAML binaries which we reccomend, then you need to reference the needed theme assembly (Telerik.Windows.Themes.Windows8.dll) and to merge the needed XAML resources in the aplication resources (App.xaml) as described in our help.

    When you set application theme through StyleManager it is propagated to all child controls as you can see in my screenshot. Check the StyleManager.Theme property.

    From your screenshot it appears that you are merging the theme resources in the application resources, is that right? However this should not affect the ListView control as we do not provide styles for it.

    Regards,
    Sia
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  6. Russell
    Russell avatar
    4 posts
    Member since:
    Sep 2016

    Posted 10 Jul in reply to Sia Link to this post

    Sia,

    Thank you for the explanation and your kindness in your response. I will give your advice a shot and report back!

    Regards

Back to Top