﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - ClientUI - Distinguish between drag-n-drop sources</title><link>http://www.intersoftsolutions.com/Community/ClientUI/Distinguish-drag-n-drop-sources/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Distinguish between drag-n-drop sources</title><link>http://www.intersoftsolutions.com/Community/ClientUI/Distinguish-drag-n-drop-sources/</link><pubDate>Fri, 13 Sep 2013 04:57:23 GMT</pubDate><dc:creator>yudi</dc:creator><category>drag-n-drop</category><description>&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;A string data is attached during &lt;strong&gt;DragInit&lt;/strong&gt; event by using following code.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;public StoreDataObjectUsingEventHandler()
{
    InitializeComponent();
    ISEventManager.RegisterInstanceHandler(
        UXListBox1, // any element in the routed path which applicable in your scenario
        ISDragDrop.DragSourceEvent, // the routed event
        new DragEventHandler(UXListBox1_DragInit), // the event handler
        true);
}
private void UXListBox1_DragInit(object sender, DragEventArgs e)
{
    string sourceData = "Some string data to store...";
    byte[] unicodeText = Encoding.Unicode.GetBytes(sourceData);
    byte[] utf8Text = Encoding.UTF8.GetBytes(sourceData);
    string uniCodeFormat = "Unicode";
    string utf8DataFormat = "UTF-8";
    var dataObject = e.Data as DragDropEventData;
    dataObject.SetData(sourceData);
    dataObject.SetData(uniCodeFormat, unicodeText);
    dataObject.SetData(utf8DataFormat, utf8Text);
}&lt;/pre&gt;
&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;The data could then be retrieved in &lt;strong&gt;PrepareDrop&lt;/strong&gt; event by invoking &lt;strong&gt;GetData()&lt;/strong&gt; method.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;public StoreDataObjectUsingEventHandler()
{
    InitializeComponent();
    ...
            
    ISEventManager.RegisterInstanceHandler(
        UXListBox2,
        ISDragDrop.PrepareDropEvent,
        new DragEventHandler(UXListBox2_PrepareDrop),
        true);
}
private void UXListBox2_PrepareDrop(object sender, DragEventArgs e)
{
    var dataObject = e.Data as DragDropEventData;
            
    if (dataObject != null)
    {
        string retrievedData = dataObject.GetData().ToString();
    }
}&lt;/pre&gt;
&lt;p&gt;&lt;span style="color: rgb(31, 73, 125);"&gt;Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Distinguish between drag-n-drop sources</title><link>http://www.intersoftsolutions.com/Community/ClientUI/Distinguish-drag-n-drop-sources/</link><pubDate>Thu, 05 Sep 2013 03:47:51 GMT</pubDate><dc:creator>mikegirkin@gmail.com</dc:creator><category>drag-n-drop</category><description>&lt;p style="font-family: 'lucida grande', 'segoe ui', arial, verdana, tahoma; line-height: 18px; margin-right: 0px; margin-left: 0px; padding: 0px; color: rgb(63, 63, 63); font-size: 12px; background-color: rgb(255, 255, 255);"&gt;Hello!&lt;/p&gt;
&lt;p style="font-family: 'lucida grande', 'segoe ui', arial, verdana, tahoma; line-height: 18px; margin-right: 0px; margin-left: 0px; padding: 0px; color: rgb(63, 63, 63); font-size: 12px; background-color: rgb(255, 255, 255);"&gt;  I have a problem using ClientUI (Silverlight).&lt;/p&gt;
&lt;p style="font-family: 'lucida grande', 'segoe ui', arial, verdana, tahoma; line-height: 18px; margin-right: 0px; margin-left: 0px; padding: 0px; color: rgb(63, 63, 63); font-size: 12px; background-color: rgb(255, 255, 255);"&gt;  I have two databound listboxes in one form with items of the same structure, the only thing that differs is data values. Those listboxes are sources for draggin items. The task is to distinguish the source of dropped items. I tried to use SetData() method on DragInit event having a goal to get this data back on Drop event. But GetData() in drop event returns null. (I tried to use the approach described here &lt;a href="http://www.intersoftpt.com/Support/ClientUI/Documentation/WalkthroughPerformDragdropUsingAPI.html#url=HowtoStoreDataObjectAtDragInitEvent.html" style="color: rgb(22, 95, 167); font-size: 10pt;"&gt;http://www.intersoftpt.com/Support/ClientUI/Documentation/WalkthroughPerformDragdropUsingAPI.html#url=HowtoStoreDataObjectAtDragInitEvent.html&lt;/a&gt;)&lt;/p&gt;
&lt;p style="font-family: 'lucida grande', 'segoe ui', arial, verdana, tahoma; line-height: 18px; margin-right: 0px; margin-left: 0px; padding: 0px; color: rgb(63, 63, 63); font-size: 12px; background-color: rgb(255, 255, 255);"&gt;  Looked through documentation, but cannot find another way of attaching custom data to the object being dragged. I hope there is a way to do this. &lt;/p&gt;</description></item></channel></rss>