2011-02-02 8 views
7

मैं एक WPF अनुप्रयोग पर काम कर रहा हूं जो अनिवार्य रूप से एक WYSIWYG संपादक है, और ड्रैग और ड्रॉप कार्यक्षमता का उपयोग कर रहा है। मेरे पास ड्रैग और ड्रॉप कार्यक्षमता काम कर रही है, लेकिन इसे अधिक सहज और उपयोगकर्ता के अनुकूल बनाने की आवश्यकता है। इसमें से एक हिस्सा वास्तव में आइटम को खींचा जा रहा है। ऐसा करने का सबसे आसान तरीका क्या है? जिन चीज़ों को मैं खींच रहा हूं वे वास्तव में कुछ खास नहीं हैं, लेकिन मुझे यह भी सुनिश्चित नहीं है कि यह कैसे करना है।मैं WPF में खींचा जा रहा आइटम कैसे दिखा सकता हूं?

उत्तर

8

आपको अन्य चीजों के साथ DragDrop.GiveFeedback का उपयोग करने की आवश्यकता होगी; जैम के पास blog post एक अलग-अलग परिदृश्यों की रूपरेखा है जिसमें से आप वर्णन करते हैं।

कर्सर हेरफेर से निपटने में जैमे के ब्लॉग पोस्ट से तुच्छ उदाहरण ...

 private void StartDragCustomCursor(MouseEventArgs e) 
     { 

      GiveFeedbackEventHandler handler = new GiveFeedbackEventHandler(DragSource_GiveFeedback); 
      this.DragSource.GiveFeedback += handler; 
      IsDragging = true; 
      DataObject data = new DataObject(System.Windows.DataFormats.Text.ToString(), "abcd"); 
      DragDropEffects de = DragDrop.DoDragDrop(this.DragSource, data, DragDropEffects.Move); 
      this.DragSource.GiveFeedback -= handler; 
      IsDragging = false; 
     } 

     void DragSource_GiveFeedback(object sender, GiveFeedbackEventArgs e) 
     { 
       try 
       { 
        //This loads the cursor from a stream .. 
        if (_allOpsCursor == null) 
        { 
         using (Stream cursorStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(
      "SimplestDragDrop.DDIcon.cur")) 
         { 
          _allOpsCursor = new Cursor(cursorStream); 
         } 
        } 
        Mouse.SetCursor(_allOpsCursor); 

        e.UseDefaultCursors = false; 
        e.Handled = true; 
       } 
       finally { } 
     } 
संबंधित मुद्दे