How to change the color of drag line indicator in WPF TreeGrid (SfTreeGrid)?
By default, SfTreeGrid does not provide the direct support to change the color of drag line indicator. You can change the color of drag line indicator by overriding the TreeGridHeaderRowControl and TreeGridRowControl Template in WPF TreeGrid.
<LinearGradientBrush x:Key="HeaderBackgroundBrush" StartPoint="0,0" EndPoint="1,1" > <GradientStop Color="Transparent" Offset="0" /> <GradientStop Color="Transparent" Offset="1" /> </LinearGradientBrush> <SolidColorBrush x:Key="HeaderBorderBrush" Color="Gray" /> <SolidColorBrush x:Key="ContentBorderBrush" Color="Gray" /> <Style TargetType="syncfusion:TreeGridHeaderRowControl"> <Setter Property="Background" Value="{StaticResource HeaderBackgroundBrush}" /> <Setter Property="BorderBrush" Value="{StaticResource HeaderBorderBrush}" /> <Setter Property="BorderThickness" Value="0" /> <Setter Property="IsTabStop" Value="False" /> <Setter Property="syncfusion:VisualContainer.WantsMouseInput" Value="True"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="syncfusion:TreeGridHeaderRowControl"> <Grid> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True"> <ContentPresenter /> </Border> <Border x:Name="PART_DragLineIndicator" BorderBrush="Red" Visibility="Collapsed" BorderThickness="0,0,0,2" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="syncfusion:TreeGridRowControl"> <Setter Property="BorderBrush" Value="{StaticResource ContentBorderBrush}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="syncfusion:TreeGridRowControl"> <Grid> <Border x:Name="PART_BackgroundBorder" Margin="{TemplateBinding IndentMargin}" Background="{TemplateBinding Background}" Visibility="Visible"> <Rectangle x:Name="PART_FocusRect" Margin="1,2,2,2" Fill="Transparent" Stroke="DarkGray" StrokeDashArray="2,2" StrokeThickness="1" Visibility="Collapsed" /> </Border> <Border x:Name="PART_SelectionBorder" Margin="{TemplateBinding IndentMargin}" Background="{TemplateBinding SelectionBackground}" Visibility="Collapsed" /> <ContentPresenter /> <Border x:Name="PART_DragLineIndicator" BorderBrush="Red" Visibility="Collapsed" BorderThickness="0,0,0,2" /> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="SelectionStates"> <VisualState x:Name="Unselected" /> <VisualState x:Name="Selected"> <Storyboard> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PART_SelectionBorder" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}" /> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="SelectedPointerOver"> <Storyboard> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PART_SelectionBorder" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}" /> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="SelectedPressed"> <Storyboard> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PART_SelectionBorder" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}" /> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="UnselectedPointerOver" /> <VisualState x:Name="UnselectedPressed" /> <VisualState x:Name="Focused"> <Storyboard> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PART_FocusRect" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}" /> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
The following screenshot shows the drag line indicator color changed,
Conclusion
I hope you enjoyed learning about how to change the color of drag line indicator in WPF TreeGrid (SfTreeGrid).
You can refer to our WPF TreeGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!