Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
141116 | Nov 25,2018 11:22 AM UTC | Dec 12,2018 11:39 AM UTC | WPF | 7 |
![]() |
Tags: SfTreeNavigator |
<navigation:SfTreeNavigator Header="EssentialStudio" NavigationMode="Extended" SelectionChanged="SfTreeNavigator_SelectionChanged"> |
/// <summary>
/// Invoked when selection changed.
/// </summary>
private void SfTreeNavigator_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
SfTreeNavigator sftree = (sender as SfTreeNavigator);
if (((sender as SfTreeNavigator).SelectedItem as SfTreeNavigatorItem).HasItems)
{
foreach (SfTreeNavigatorItem item in (sftree.SelectedItem as SfTreeNavigatorItem).Items)
{
item.Background = new SolidColorBrush(Colors.Red);
}
}
} |
<SolidColorBrush x:Key="SelectedBackground" Color="Green"/>
<SolidColorBrush x:Key="UnSelectedItemBackground" Color="Red"/>
<SolidColorBrush x:Key="SelectedHeaderBackground" Color="Green"/>
<Style TargetType="navigation:SfTreeNavigatorItem">
<Setter Property="BorderThickness" Value="0 0 0 0"/>
<Setter Property="BorderBrush" Value="#5D5D5D"/>
<Setter Property="Height" Value="40"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="navigation:SfTreeNavigatorItem">
<Border Background="{StaticResource UnSelectedItemBackground}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SelectionStates">
|
<!--Background color of TreeNavigatorItems host-->
<Setter Property="Background" Value="Red"/>
<!--HeaderItem Backgroud color-->
<Setter Property="Background" Value="Green"/>
//Color which applies to child item after navigation
if (((sender as SfTreeNavigator).SelectedItem as SfTreeNavigatorItem).HasItems)
{
foreach (SfTreeNavigatorItem item in (sftree.SelectedItem as SfTreeNavigatorItem).Items)
{
item.Background = new SolidColorBrush(Colors.DeepSkyBlue);
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.