NoesisGUI
 

🔹 DragDrop Class

namespace NoesisApp

Provides attached properties to simplify drag-and-drop operations without custom code-behind.

Allows defining drag sources, drop targets, compatibility matching, and floating visual overlays purely through XAML.

Usage example:

<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions"
  noesis:DragDropExtensions.IsOverlayHost="True">

  <!-- Define a custom floating template -->
  <Grid.Resources>
    <DataTemplate x:Key="DragOverlayTemplate">
      <Border BorderBrush="Cyan" BorderThickness="2" Background="#88000000">
        <TextBlock Text="{Binding Name}" Foreground="White" />
      </Border>
    </DataTemplate>
  </Grid.Resources>

  <StackPanel Orientation="Horizontal">

    <!-- A draggable item -->
    <ContentControl Content="{Binding SwordItem}"
      noesis:DragDropExtensions.Role="DragOnly"
      noesis:DragDropExtensions.Kind="Weapon"
      noesis:DragDropExtensions.OverlayTemplate="{StaticResource DragOverlayTemplate}">
      <ContentControl.ContentTemplate>
        <DataTemplate>
          <Image Source="sword.png" Width="64" Height="64"/>
        </DataTemplate>
      </ContentControl.ContentTemplate>
    </ContentControl>

    <!-- A target slot that only accepts 'Weapon' kinds -->
    <ContentControl noesis:DragDropExtensions.Role="DropOnly"
      noesis:DragDropExtensions.Kind="Weapon"
      noesis:DragDropExtensions.MatchKind="True"
      noesis:DragDropExtensions.Transfer="Move"
      Width="64" Height="64" Background="DarkGray">

      <ContentControl.Style>
        <Style TargetType="ContentControl">
          <Style.Triggers>
            <!-- Highlight the slot when a compatible item is dragged over it -->
            <Trigger Property="noesis:DragDropExtensions.IsHoverCompatible" Value="True">
              <Setter Property="Background" Value="LightGreen" />
            </Trigger>
          </Style.Triggers>
        </Style>
      </ContentControl.Style>
    </ContentControl>

  </StackPanel>
</Grid>

Inheritance Hierarchy

• DragDrop

📚 Class Hierarchy Index

Properties

DragDrop has no properties

Attached Properties

Name Description
◆ AutoTransfer If true (default), a quick transfer instantly moves the content to the first compatible target. When false, initiating a quick transfer enters targeting mode by shifting the keyboard focus to the target so the user can manually navigate and confirm the destination
◆ CancelKey The keyboard key used to cancel an ongoing drag-and-drop operation
◆ DefaultContent The content to inject into a source element after its original content is Moved or Swapped
◆ EmptyContentPath Property path or name used to evaluate if the control content is considered empty
◆ IsContentEmpty Set to True when the element's content is evaluated as empty
◆ IsDropCompatible Set to True on all potential targets when a compatible drag operation starts
◆ IsHoverCompatible Set to True on a target when a compatible dragged item is currently hovering over it
◆ IsOverlayCompatible Set to True on the floating overlay when it is hovering over a compatible target
◆ IsOverlayHost Identifies a Panel as the root host for rendering the dragged floating overlay
◆ Kind An arbitrary object (often a string) used to group compatible sources and targets
◆ MatchKind If true, a drop will only be allowed if the source's Kind matches the target's Kind
◆ OverlayTemplate Defines a custom DataTemplate for the floating overlay (defaults to the source's template). This property is inherited, so you can define the overlay template at any level in your UI
◆ Role Defines whether the element acts as a drag source, a drop target, or both. Setting this property automatically injects the required interaction behaviors
◆ SourceInFlight The source content control that initiated the drag and drop operation in progress
◆ Tag Arbitrary user data attached to the drag-and-drop element
◆ Transfer Defines what happens to the underlying Content when a drop succeeds (Move, Copy, Swap)
◆ TransferKey The keyboard key used to initiate a quick transfer
◆ TransferMouseButton The mouse button used to initiate a quick transfer

Methods

DragDrop has no methods

Events

DragDrop has no events

 
© 2017 Noesis Technologies