Hi all,
I want to enable close button of message box window .I am trying this code but close button is not enable.
if (MessageBox.Show("Do you want to close this window?", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
// Close the window
}
else
{
// Do not close the window
}
Thanks
Aniruddha

venkata kumarRank #5,034 · 314 reputationPosted Dec 24, 2012, 1:52 AM EST
try this
DialogResult dialog = MessageBox.Show("Do You Want To Continue?", "", MessageBoxButtons.YesNo,MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
if (dialog == DialogResult.Yes)
{
}
else if (dialog == DialogResult.No)
{
}
Sivaraman DhamodaranRank #40 · 34.5K reputationPosted Dec 24, 2012, 2:30 AM EST
Displaying the same message box with MessageBoxButton.Yes will enabled the close button
VulpesRank #55 · 29.2K reputationPosted Dec 24, 2012, 4:58 AM EST
If the user clicks the Close button, the Cancel button will then be deemed to have been pressed by default.
However, there's no way to keep the MessageBox open after the user has pressed a button - and, even if there was, I can't see why you'd want to.