Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3220
xamPropertyGrid confirm delete list item
posted

Hello,

is it possible to interact when the user clicks on the "remove" button on the list item in the property grid, in order I can show a confirm "Delete" dialog?

See attached image.

Parents
  • 2151
    Verified Answer
    Offline posted

    Hello Markus,

    You can achieve the requested functionality by attaching an event handler to the xamPropertyGrid's "CommandExecuting" event and handle it the following way:
    - check if the command is "RemoveListEntry"
    - perform some additional checking (if necessary)
    - show the removal confirm dialog
    - cancel the event if the user does not confirm removal (which will cancel the CommandExecuted event and ultimately cancel the list item removal)

    Here is an example on how you may implement it:

    private void XamPropertyGrid1_CommandExecuting(object sender, PropertyGridCommandExecutingEventArgs e)
    {
        if (e.Command == PropertyGridCommandType.RemoveListEntry)
        {
            var result = MessageBox.Show("Are you sure you want to delete?", "Confirm", MessageBoxButton.YesNo);
            if (result != MessageBoxResult.Yes)
            {
                e.Cancel = true;
            }
        }
    }

    Let me know if I may be of any further assistance.

    Sincerely,
    Radko Kolev
    Senior Software Developer

Reply Children
No Data