Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Styling a Drag and Drop Items behavior in a WPF ListView

Styling a Drag and Drop Items behavior in a WPF ListView

Scheduled Pinned Locked Moved WPF
csharpjavascriptdatabasewpfwinforms
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kenneth Haugland
    wrote on last edited by
    #1

    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>
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups