Reset colors after setting style

11 posts, 0 answers
  1. rico
    rico avatar
    15 posts
    Member since:
    Aug 2017

    Posted 10 Aug Link to this post

    To bind the IsExpanded Property to my own IsExpanded property I use the following snippet:

    <Style TargetType="{x:Type telerik:RadTreeViewItem}" x:Key="ItemContainerStyle"  >
        <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded,Mode=TwoWay}"/>
    </Style>

    This works fine so far but the highlight color of the nodes turned from blue into grey. How can I keep the original style and only add the setter property?

  2. Sia
    Admin
    Sia avatar
    685 posts

    Posted 15 Aug Link to this post

    Hello,

    I will need some details about your implementation:
    1. Which is the theme that you use in your application?
    2. Which is the theming mechanism that you use - StyleManager or implicit themes?

    Generally we recommend using implicit style that targets RadTreeViewItem instead of using the ItemContainerStyle property. You need to base it on our style by setting BasedOn as follows:
    <Style TargetType="{x:Type telerik:RadTreeViewItem}" BasedOn="{StaticResource RadTreeViewItemStyle}"  >
        <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded,Mode=TwoWay}"/>
    </Style>


    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.
  3. rico
    rico avatar
    15 posts
    Member since:
    Aug 2017

    Posted 16 Aug in reply to Sia Link to this post

    Thank your for your answer.
     
    Where do I find the information about which theme and theming mechanism we use? I would say it is all default.

    Your solution doesn't work for me because RadTreeViewItemStyle is not in the StaticResources.

  4. Sia
    Admin
    Sia avatar
    685 posts

    Posted 17 Aug Link to this post

    Hello,

    It seems that you use our OfficeBlack theme with XAML binaries (or said another way - StyleManager). More information about styling Telerik UI for WPF controls can be found in our documentation.

    Still I am not sure which is the blue color that is missing since in our Office Black theme there is only gray and orange highlights as seen from the attached screenshot.

    Do you set ApplicationTheme somewhere in your application? ]
    StyleManager.ApplicationTheme = new Office_BlackTheme();


    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.
  5. rico
    rico avatar
    15 posts
    Member since:
    Aug 2017

    Posted 17 Aug in reply to Sia Link to this post

    Indeed we do: We use the Windows8Theme and adjust further settings such as its palette.

  6. rico
    rico avatar
    15 posts
    Member since:
    Aug 2017

    Posted 18 Aug in reply to rico Link to this post

    Before adding the style element the color of a selected element was the AccentColor (blue) of the Windows8Palette. After adding the style element it seems to use the BasicColor (gray) of the Windows8Palette. I don't know what exactly is going on but comparing the RGB values shows this color switch.
  7. Sia
    Admin
    Sia avatar
    685 posts

    Posted 22 Aug Link to this post

    Hello,

    Still I am not sure what causes the described issue. Please find attached a simple project with a TreeView where a custom ItemContainerStyle is set. By default the TreeView has gray background for MouseOver and Selected states of its items as seen from the attached screenshot. You said that there was an accent color before setting the style which disappeared which means that you have customized some of the palette colors as you said before. Can you modify the project with all palette settings so I can check what could be wrong with it?

    Again if you use NoXAML binaries and merge the needed theme resources, such custom styles as the ItemContainerStyle one need to be based on ours. But if your case is setting a theme by StyleManager, then everything should work as expected.

    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.
  8. rico
    rico avatar
    15 posts
    Member since:
    Aug 2017

    Posted 25 Aug Link to this post

    I've figured out the answer. I didn't put the style element into a merged dictionary.

    This here works:

    <telerik:radGridView.Resources>

      <ResourceDictionary>

        <ResourceDictionary.MergedDictionaries>

          <ResourceDictionary>

            <Style TargetType="{x:Type telerik:RadTreeViewItem}" x:Key="ItemContainerStyle"  >
              <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded,Mode=TwoWay}"/>
            < /Style>

          </ResourceDictionary>

        </ResourceDictionary.MergedDictionaries>

      </ResourceDictionary>

    </telerik:radGridView.Resources>

  9. rico
    rico avatar
    15 posts
    Member since:
    Aug 2017

    Posted 25 Aug in reply to rico Link to this post

    Sorry, false alarm. Doesn't work.
  10. Sia
    Admin
    Sia avatar
    685 posts

    Posted 28 Aug Link to this post

    Hello,

    Could you please modify the previously attached project, so I can observe the exact setup of the resources in your application? Also the theming mechanism is important - do you use StyleManager or implicit styles? Otherwise it is difficult to understand what causes the unwanted behavior.

    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.
  11. rico
    rico avatar
    15 posts
    Member since:
    Aug 2017

    Posted 13 Sep in reply to Sia Link to this post

    I finally got the answer. I overwrote our custom style from another assembly. This here works:

    <telerik:radGridView.Resources>
      <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/OtherAssembly,component/existingStyles.xaml />
        </ResourceDictionary.MergedDictionaries>
        <Style BasedOn="{StaticResource xKeyOfStyleToExtendFromExistingStyles}" TargetType="{x:Type telerik:RadTreeViewItem}">
            <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}"/>
        </Style>
      </ResourceDictionary>
    </telerik:radGridView.Resources>
Back to Top