# C1.WPF.C1DragDropManager.RegisterDragSource

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_WPF_C1DragDropManager_RegisterDragSource_" data-uid="C1.WPF.C1DragDropManager.RegisterDragSource*">RegisterDragSource Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_WPF_C1DragDropManager_RegisterDragSource_" data-uid="C1.WPF.C1DragDropManager.RegisterDragSource*"></a>
<h4 id="C1_WPF_C1DragDropManager_RegisterDragSource_System_Windows_UIElement_C1_WPF_DragDropEffect_System_Windows_Input_ModifierKeys_System_Boolean_" data-uid="C1.WPF.C1DragDropManager.RegisterDragSource(System.Windows.UIElement,C1.WPF.DragDropEffect,System.Windows.Input.ModifierKeys,System.Boolean)">RegisterDragSource(UIElement, DragDropEffect, ModifierKeys, bool)</h4>
<div class="markdown level1 summary"><p>Registers a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.uielement">UIElement</a> to act as a drag source.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void RegisterDragSource(UIElement source, DragDropEffect effect, ModifierKeys keys, bool handledEventsToo = false)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub RegisterDragSource(source As UIElement, effect As DragDropEffect, keys As ModifierKeys, Optional handledEventsToo As Boolean = False)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.uielement">UIElement</a></td>
      <td><span class="parametername">source</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.uielement">UIElement</a> that will act as a drag source.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.WPF.DragDropEffect.html">DragDropEffect</a></td>
      <td><span class="parametername">effect</span></td>
      <td><p><a class="xref" href="C1.WPF.DragDropEffect.html">DragDropEffect</a> that will be supported by the <code class="paramref">source</code> object.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.input.modifierkeys">ModifierKeys</a></td>
      <td><span class="parametername">keys</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.input.modifierkeys">ModifierKeys</a> that should be pressed in order for the drag operation to start.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">handledEventsToo</span></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 id="C1_WPF_C1DragDropManager_RegisterDragSource_System_Windows_UIElement_C1_WPF_DragDropEffect_System_Windows_Input_ModifierKeys_System_Boolean__remarks">Remarks</h5>
<div class="markdown level1 remarks"><pre><code>&lt;p&gt;When a &lt;xref href=&quot;System.Windows.UIElement&quot; data-throw-if-not-resolved=&quot;false&quot;&gt;&lt;/xref&gt; is registered as a drag source, the &lt;xref href=&quot;C1.WPF.C1DragDropManager&quot; data-throw-if-not-resolved=&quot;false&quot;&gt;&lt;/xref&gt; 
</code></pre>
<p>monitors the mouse events for that element and starts drag-drop operations automatically when the user
presses the mouse over the element and moves it for a few pixels.</p>
<p>This is a convenience method, it is not strictly required; you could handle the mouse events
for the objects you want to use as drag sources and call the <a class="xref" href="C1.WPF.C1DragDropManager.DoDragDrop.html#C1_WPF_C1DragDropManager_DoDragDrop_System_Windows_UIElement_System_Windows_Input_MouseEventArgs_C1_WPF_DragDropEffect_">DoDragDrop(UIElement, MouseEventArgs, DragDropEffect)</a> method
explicitly.</p>
<p>To un-register an element as a drag source, call the <b>RegisterDragSource</b> method passing
the element and <b>DragDropEffect.None</b>.</p>
<p>Note that only elements that raise mouse events may be used as automatic drag sources.
For example, the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.controls.button">Button</a> and <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.controls.textbox">TextBox</a> controls consume mouse events
internally, so the <a class="xref" href="C1.WPF.C1DragDropManager.html">C1DragDropManager</a> does not receive any mouse events for these controls.
Therefore, they cannot be used as automatic drag sources.</p>
</div>
</div>
