locked
Non-dismissable message dialog in Windows Phone 8.1?

    Question

  • I need a non-dismissable messagebox dialog for my universal app. On Windows Phone, the user can dismiss the dialog with the back button without making a choice. Can I stop this behavior somehow?

    There is the cancelCommandIncex property that according to http://msdn.microsoft.com/en-US/library/windows/apps/windows.ui.popups.messagedialog.cancelcommandindex.aspx

    can be set to -1 to require the user to make a decision. However, cancelCommandIndex expects a uint which cannot be negative. Am I missing something?

    I tried to handle HardwareButtons.BackPressed myself, but that only works on the UI and not the Message Dialog. Ideas?

    Thanks!

    Sunday, October 05, 2014 4:05 PM

Answers

  • Try this:

    md.CancelCommandIndex = unchecked((uint)-1);
    You could also use the hex value: 0xFFFFFFFF;

    I'm not sure what you're doing differently, but my MessageDialogs dismissed on Escape when I didn't pass the -1.





    Thursday, October 09, 2014 10:51 PM
    Owner

All replies

  • You can cast -1 to a uint: (uint)-1
    Sunday, October 05, 2014 5:50 PM
    Owner
  • You can cast -1 to a uint: (uint)-1

    Hm. That gives me the error "Constant value -1 cannot be converted to a uint (use unchecked syntax to override".

    message.CancelCommandIndex = unchecked(-1) gives the error "Constant value -1 cannot be converted to a uint". (I might be using the keyword wrong though).

    Btw, turns out, MessageDialog seems to me non-dismissable on Windows 8 by default, at least I cannot dismiss it with ESC. Hmm.

    Thursday, October 09, 2014 5:03 PM
  • Try this:

    md.CancelCommandIndex = unchecked((uint)-1);
    You could also use the hex value: 0xFFFFFFFF;

    I'm not sure what you're doing differently, but my MessageDialogs dismissed on Escape when I didn't pass the -1.





    Thursday, October 09, 2014 10:51 PM
    Owner