locked
Custom Save buttons and messagebox with confirmation RRS feed

  • Question

  • How can I create a Message Box with the two normal buttons of "Yes" and "No" asking me if I'm sure I want to Save?

    Same to close without saving.

    Where to place them in code I know. I juist don't know where I can find them or how to create them with LighSwitch.


    • Edited by joao_silva Tuesday, June 11, 2013 11:52 AM
    Tuesday, June 11, 2013 11:52 AM

Answers

  • Hello

    I think that you are over thinking this. Personally I would create a button on the screen and then in the execute method put the following

    partial void CloseWithoutSave_Execute() { // Write your code here. if (this.ShowMessageBox("Are you sure that you want to close without saving?","Cancel Record?",MessageBoxOption.YesNo) == System.Windows.MessageBoxResult.Yes) { this.DataWorkspace.YourDataConnection.Details.DiscardChanges();

    } } partial void MyCustomSave_Execute() { // Write your code here. if (this.ShowMessageBox("Are you sure that you want to save this record?","Save Record?",MessageBoxOption.YesNo) == System.Windows.MessageBoxResult.Yes) { this.Save();

    } }

    Of course you need to replace YourDataConnection with Your data connection.

    HTH


    If you found this post helpful, please mark it as helpful. If by some chance I answered the question, please mark the question as answered. That way you will help more people like me :)


    • Edited by Otis Ranger Tuesday, June 11, 2013 12:54 PM
    • Proposed as answer by Otis Ranger Tuesday, June 11, 2013 12:54 PM
    • Marked as answer by joao_silva Tuesday, June 11, 2013 3:33 PM
    Tuesday, June 11, 2013 12:52 PM

All replies

  • Hello

    I think that you are over thinking this. Personally I would create a button on the screen and then in the execute method put the following

    partial void CloseWithoutSave_Execute() { // Write your code here. if (this.ShowMessageBox("Are you sure that you want to close without saving?","Cancel Record?",MessageBoxOption.YesNo) == System.Windows.MessageBoxResult.Yes) { this.DataWorkspace.YourDataConnection.Details.DiscardChanges();

    } } partial void MyCustomSave_Execute() { // Write your code here. if (this.ShowMessageBox("Are you sure that you want to save this record?","Save Record?",MessageBoxOption.YesNo) == System.Windows.MessageBoxResult.Yes) { this.Save();

    } }

    Of course you need to replace YourDataConnection with Your data connection.

    HTH


    If you found this post helpful, please mark it as helpful. If by some chance I answered the question, please mark the question as answered. That way you will help more people like me :)


    • Edited by Otis Ranger Tuesday, June 11, 2013 12:54 PM
    • Proposed as answer by Otis Ranger Tuesday, June 11, 2013 12:54 PM
    • Marked as answer by joao_silva Tuesday, June 11, 2013 3:33 PM
    Tuesday, June 11, 2013 12:52 PM
  • Thanks Otis, it's a solution.

    I'll try to implemente it, although in definitive I will try to implement the message box with Buttons.

    Tuesday, June 11, 2013 3:32 PM
  • Probably not exactly what your are looking for:

    VALIDATION WARNINGS WITH AN ON SCREEN CONFIRMATION BOX


    paul van bladel

    Tuesday, June 11, 2013 4:18 PM
  • Hi,

    Here is the my blogpost which will help you in making any kind of custom message box easily. Kindly check it and give me feedback.

    There is also a sample project with it.

    Click the link below to see the blogpost

    http://smhsg.blogspot.com/2013/07/custom-message-box-for-windows-phone-7-8.html

    Thanks

    Regards Mudassir

    Monday, July 22, 2013 3:01 AM