How to change default selected item colour

3 posts, 0 answers
  1. wpfdev
    wpfdev avatar
    11 posts
    Member since:
    Mar 2010

    Posted 13 Aug 2010 Link to this post

    Hello,

    How could I change the default colour when a mouse moves over a treeview item? Also, how could I change the default colour when a treeview item is selected?

    Thanks.
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 18 Aug 2010 Link to this post

    Hello wpfdev,

    In order to apply these changes you have to edit the ControlTemplate of the RadTreeView in Blend. More information you can find here.

    Then you will be able to modify the default style of the RadTreeView to match your requirements.

    In order to modify the MouseOver and Selected background color of the RadTreeViewItem you can modify the MouseOver/Selected resource brushes - ControlSubItem_OuterBorder_MouseOver, ControlSubItem_InnerBorder_MouseOver, ControlSubItem_Background_MouseOver and ControlSubItem_OuterBorder_Selected, ControlSubItem_InnerBorder_Selected, ControlSubItem_Background_Selected.

    Another approach is to set the new values in the MouseOver and SelectionVisual Borders:
    <!--MouseOver Borders-->
    <Border x:Name="MouseOverVisual" Grid.ColumnSpan="6" Grid.Column="2" Opacity="0"
            BorderThickness="{StaticResource ControlSubItem_OuterBorderThickness}"
            BorderBrush="{StaticResource ControlSubItem_OuterBorder_MouseOver}"
            CornerRadius="{StaticResource ControlSubItem_OuterCornerRadius}">
        <Border BorderBrush="{StaticResource ControlSubItem_InnerBorder_MouseOver}"
            BorderThickness="{StaticResource ControlSubItem_InnerBorderThickness}"
            Background="{StaticResource ControlSubItem_Background_MouseOver}"
            CornerRadius="{StaticResource ControlSubItem_InnerCornerRadius}"/>
    </Border>
                         
    ...
     
    <!--SelectionVisual Borders-->
    <Border x:Name="SelectionVisual" Grid.ColumnSpan="6" Grid.Column="2" Visibility="Collapsed"
            BorderBrush="{StaticResource ControlSubItem_OuterBorder_Selected}"
            BorderThickness="{StaticResource ControlSubItem_OuterBorderThickness}"
            CornerRadius="{StaticResource ControlSubItem_OuterCornerRadius}">
        <Border BorderBrush="{StaticResource ControlSubItem_InnerBorder_Selected}"
            BorderThickness="{StaticResource ControlSubItem_InnerBorderThickness}"
            Background="{StaticResource ControlSubItem_Background_Selected}"
            CornerRadius="{StaticResource ControlSubItem_InnerCornerRadius}"/>
    </Border>

    I prepared a sample project illustrating the first approach. Please take a look at it and let me know if it works for you or if you need more info.

    Regards,
    Tina Stancheva
    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. wpfdev
    wpfdev avatar
    11 posts
    Member since:
    Mar 2010

    Posted 19 Aug 2010 Link to this post

    It helps. Thanks.
Back to Top