This is a migrated thread and some comments may be shown as answers.

Limit the number of Drops and User Confirmation

2 Answers 46 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 20 Jun 2014, 11:46 AM
How to limit the number of drops. I am using drag Drop between 2 RadListBoxes. Do you have any similar sample?
How to drop after user approves?
 

2 Answers, 1 is accepted

Sort by
0
Andy
Top achievements
Rank 1
answered on 20 Jun 2014, 11:54 AM
Also adding a little more requirement in it. Limiting the number but at the same time allowing new drops - it is like let the new drops come in but the old drops (beyond certain limit) will go out automatically.
0
Kalin
Telerik team
answered on 24 Jun 2014, 10:20 AM
Hello Andy,

I'm not completely sure if I understand correctly your question. Regarding the first one if you need to cancel or confirm the drop depending on confirmation from the user - you can do that in the Drop handler of the targeted ListBox. Inside of the handler you can show a MessageBox for example and if the drop is not confirmed to handle the event by setting the e.Handled to true. For example check the following code snippet:

private void OnDropHandler(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
{
    var messageBoxResult = MessageBox.Show("Are you sure?", "Drop Confirmation", System.Windows.MessageBoxButton.YesNo);
 
    if (messageBoxResult == MessageBoxResult.Yes)
    {
        // custom drop logic
    }
 
    // in both cases handle the event
    e.Handled = true;
}

As for the second question, I'll ask you to share some more information on the desired scenario as it is not completely clear. If need to keep only particular number of items as ItemsSource of the target ListBox you would need to manually remove one and add the new one in the Drop handler.

Hope this helps.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
DragAndDrop
Asked by
Andy
Top achievements
Rank 1
Answers by
Andy
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or