<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);
}
} |