ookii-dialogs / ookii-dialogs-wpf

Awesome dialogs for Windows Desktop applications built with Microsoft .NET (WPF)
BSD 3-Clause "New" or "Revised" License
1.14k stars 85 forks source link

NullReferenceException when showing TaskDialog without buttons #48

Closed mgpreston closed 3 years ago

mgpreston commented 3 years ago

If you attempt to call ShowDialog on a TaskDialog that you haven't added any buttons to, the call to ShowDialog will throw a NullReferenceException.

Could this be improved to throw a more meaningful exception - or perhaps add a default button to it?

Example:

var dialog = new Ookii.Dialogs.Wpf.TaskDialog {
    Content = "Message",
    MainInstruction = "Instruction"
};

dialog.ShowDialog(); // NullReferenceException here. dialog is not null.

Thank you!

augustoproiete commented 3 years ago

Thanks for reporting @mgpreston. I fixed the NullReferenceException so that a more meaningful exception is thrown, but showing a default button might be a better experience.

What do you think the button should be? OK? Close? Cancel? Something else?

mgpreston commented 3 years ago

That's great, thanks!

I would be tempted to go for OK as the default button, but I'd consider any of them to be fine.

augustoproiete commented 3 years ago

Tracking adding the default button via https://github.com/ookii-dialogs/ookii-dialogs-wpf/issues/55

Closing this one as fixed by 5582dcb

augustoproiete commented 3 years ago

:tada: This issue has been resolved in Ookii.Dialogs.Wpf v4.0.0

The release is available on: