Beispiel #1
0
        private void column_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("data"))
            {
                CardDragData data = e.Data.GetData("data") as CardDragData;
                ObservableCollection <Karte> sourceCards = data.Cards;
                ObservableCollection <Karte> targetCards = GetItemsSource(sender);
                Karte movedCard = data.Card;

                sourceCards.Remove(movedCard);
                targetCards.Add(movedCard);
            }
        }
Beispiel #2
0
        private void Image_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                Image img  = (Image)sender;
                Karte card = (Karte)img.DataContext;

                ItemsControl parent      = FindAncestor <ItemsControl>(img);
                var          itemsSource = GetItemsSource(parent);

                // Initialize the drag & drop operation
                var        dragData   = new CardDragData(itemsSource, card);
                DataObject dataObject = new DataObject("data", dragData);
                DragDrop.DoDragDrop(img, dataObject, DragDropEffects.Move);
            }
        }