Styling a Drag and Drop Items behavior in a WPF ListView
WPF
1
Posts
1
Posters
0
Views
1
Watching
-
So, I basically took the reordering from Josh Smith: Drag and Drop Items in a WPF ListView[^] All I wanted to do now was to draw a line where the new item was inserted, with an arrow. Like the old WinForms style behavior: Manual reordering of items inside a ListView[^] The line under was easy to achieve, all I had to was to alter the Style:
<Style.Resources> <LinearGradientBrush x:Key="MouseOverBrush" StartPoint="0.5, 0" EndPoint="0.5, 1"> <GradientStop Color="#22000000" Offset="0" /> <GradientStop Color="#44000000" Offset="0.4" /> <GradientStop Color="#55000000" Offset="0.6" /> <GradientStop Color="#33000000" Offset="0.9" /> <GradientStop Color="#22000000" Offset="1" /> </LinearGradientBrush> <SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#DDD" /> <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" /> </Style.Resources> <Setter Property="Padding" Value="0,4" /> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> <!-- The default control template for ListViewItem has a Border which contains the item's content. --> <Setter Property="Border.BorderThickness" Value="0,0,0,0.5" /> <Setter Property="Border.BorderBrush" Value="Transparent"/> <!-- These triggers react to changes in the attached properties set during a managed drag-drop operation. --> <Style.Triggers> <Trigger Property="jas:ListViewItemDragState.IsBeingDragged" Value="True"> <Setter Property="FontWeight" Value="DemiBold" /> </Trigger> <Trigger Property="jas:ListViewItemDragState.IsUnderDragCursor" Value="True"> <Setter Property="Border.BorderThickness" Value="0,0,0,0.5" /> <Setter Property="Border.BorderBrush" Value="Red"</x-turndown>