Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Problem with D&D from list box to the screen

$
0
0

HI,

Im using the following code to D&D from list box to textBox which is working great,currently I got problem

when I drag item from the list box and by mistake drop it into the screen but not in text box now i cant take

the item which i drag to screen and do with it noting I just need to pick new item from the list and drag it to text box

and than I can drag it again .there is a way to check if the item which was drag is drop in the text box?

This is the code which i use and its calling to the DoDragDrop method even if I drag it to the wrong place in the screen(not to the text box),any idea?

        private void listbox_SelectionChanged(object sender, RoutedEventArgs routedEventArgs)
        {
            if (sender is ListBox)
            {
                var listBox = sender as ListBox;

                if (listBox.SelectedItem != null)
                {
                    var mySelectedItem = listBox.SelectedItem as User;

                    if (mySelectedItem != null)
                    {
                        DragDrop.DoDragDrop(listBox, mySelectedItem,
                                           DragDropEffects.Copy | DragDropEffects.Move);
                    }
                }
            }
        }




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>