Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, when I have one instance of CustomMessageBox (from the WP Toolkit, this code is for Windows Phone 8) and try to use Show() more than 1 time (for example in an event handler):
C#
public partial class MainPage : PhoneApplicationPage
{
        private CustomMessageBox jumpPanel = new CustomMessageBox();

        ...
    
        private void SomeThing_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            ...

            jumpPanel.Show();
        }
}

I get InvalidOperationException by the second call (note that Dismiss() was called in the meantime). However, when I "renew" the object every time:
C#
private void SomeThing_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
    jumpPanel = new CustomMessageBox();

    ...

    jumpPanel.Show();
}

It's alright. I wonder what the cause is? Why does it need to create a new instance? Note that I tried few Show() and Dismiss() calls in a row in the first case and it was alright. Thank you in advance.
Posted
Updated 16-Feb-14 1:11am
v3
Comments
Maarten Kools 15-Feb-14 17:47pm    
Is there no message in the exception? It might give you a hint what is going on.
Member 10599476 15-Feb-14 17:54pm    
Only general statements.
Richard Andrew x64 15-Feb-14 21:13pm    
MSDN says that you'll get that exception in the following circumstances:

The form being shown is already visible.

-or-

The form specified in the owner parameter is the same as the form being shown.

-or-

The form being shown is disabled.

-or-

The form being shown is not a top-level window.

-or-

The form being shown as a dialog box is already a modal form.

-or-

The current process is not running in user interactive mode
Member 10599476 16-Feb-14 7:06am    
I consider the "top-level window" cause, because as I wrote above, if I call few Show() and Dismiss() in a row (in one function), there is no such problem, so this is caused perhaps by "getting out" of the function and interacting with other entities. I have just tried calling Focus() before, but no change.
Sergey Alexandrovich Kryukov 15-Feb-14 21:16pm    
CustomMessageBox? There is not such class in .NET FCL. Any reference?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900