5

How to create a dialog window or something similar to confirm a delete action before deleting a datagrid row?

stijn
  • 34,664
  • 13
  • 111
  • 163
Tinaira
  • 727
  • 2
  • 7
  • 23

1 Answers1

2

In WPF there are "preview" events that get called before the "standard" event gets called. These events have the word Preview prefixed on the event name (i.e. PreviewMouseDown). In the "preview" event you can display a MessageBox, or something similar, asking the user to confirm the deletion. If the user confirms the deletion let the event continue. Otherwise you can mark the event as handled and the "standard" event will not execute.

Phillip
  • 94
  • 4
  • this sounds good. can you guide me step by step how this works? – Tinaira Nov 18 '15 at 21:05
  • 1
    Sure. I'll put together a little example and post it here. Until then visit [WPF Tutorial.net](http://www.wpftutorial.net). It has some great info especially for newbies. – Phillip Nov 18 '15 at 21:31
  • 1
    So, there was too many characters to add the code samples here, so I put them on my blog. My blog is at [http://killerbytz.blogspot.com/2015/11/routed-events-example.html](http://killerbytz.blogspot.com/2015/11/routed-events-example.html) – Phillip Nov 19 '15 at 02:01