Limit the number of Drops and User Confirmation

3 posts, 0 answers
  1. Andy
    Andy avatar
    13 posts
    Member since:
    Apr 2014

    Posted 20 Jun 2014 Link to this post

    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. Andy
    Andy avatar
    13 posts
    Member since:
    Apr 2014

    Posted 20 Jun 2014 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 24 Jun 2014 Link to this post

    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.
     
Back to Top