Advertisement
andrzejiwaniuk

[Napisz sam] Technika przeciągnij i upuść

Jun 13th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15.  
  16. namespace DragAndDrop
  17. {
  18.     /// <summary>
  19.     /// Logika interakcji dla klasy MainWindow.xaml
  20.     /// </summary>
  21.     public partial class MainWindow : Window
  22.     {
  23.         public MainWindow()
  24.         {
  25.             InitializeComponent();
  26.         }
  27.         private void rect_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  28.         {
  29.             Rectangle r = (Rectangle)sender;
  30.             DataObject dataObj = new DataObject(r.Fill);
  31.             DragDrop.DoDragDrop(r, dataObj, DragDropEffects.Move);
  32.         }
  33.  
  34.         private void Rectangle_Drop(object sender, DragEventArgs e)
  35.         {
  36.             SolidColorBrush scb = (SolidColorBrush)e.Data.GetData(typeof(SolidColorBrush));
  37.             Target.Fill = scb;
  38.         }
  39.  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement