This is a migrated thread and some comments may be shown as answers.

When 'Cancel' button is pressed to stay on the page, the ApplicationBar is vanishing

3 Answers 57 Views
MessageBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Shantimohan
Top achievements
Rank 1
Shantimohan asked on 15 Jul 2012, 11:23 PM
I am using RadMessageBox inside the OnBackKeyPressed event with some plumbing necessary to manage the non-modal running.

For either Save or Discard button, finally I GoBack(). So I don't have any problem. But when the cancel is pressed, I want to stay in the current page. Yes, it does stay in the current page but the ApplicationBar is vanishing.

My code is as below:
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
    if (popup1.IsOpen)
    {
        popup1.IsOpen = false;
 
        e.Cancel = true;
    }
    else
    {
        if (TaskModified())
        {
            if (!isBackKeyInProgress)
            {
                RadMessageBox.Show(new CustomHeaderedContentControl[]
            {
                new CustomHeaderedContentControl() { Title = "Save", Message = "This details will be saved to the database." },
                new CustomHeaderedContentControl() { Title = "Discard", Message = "This details will NOT be saved to the database." },
                new CustomHeaderedContentControl() { Title = "Cancel", Message = "Returns to the details for further editing." }
            },
            "Back Key Pressed",
            "You are about to close the details editor. What do you want to do?",
            closedHandler: (args) =>
            {
                // ClickedButton will be null in the case when RadMessageBox is closed because the user pressed the hardware back button.
                if (args.ClickedButton == null)
                {
                    DiscardTask();
                }
 
                CustomHeaderedContentControl option = (CustomHeaderedContentControl)args.ClickedButton.Content;
                if (option.Title == "Save")
                {
                    SaveTask(false);
                }
 
                if (option.Title == "Discard")
                {
                    DiscardTask();
                }
 
                if (option.Title == "Cancel")
                {
                    // Return to editing the task.
                    SystemTray.SetProgressIndicator(this, null);
                    return;
                }
            });
 
            isBackKeyInProgress = true;
            e.Cancel = true;
        }
    }
 
    if (!isBackKeyInProgress)
        NavigateBack(true);
    SystemTray.SetProgressIndicator(this, App.sysProgressBar);
}

How can I make the ApplicationBar not vanish? Was it because I am using it in the OnBackKeyPressed event?

ThanQ...

3 Answers, 1 is accepted

Sort by
0
Shantimohan
Top achievements
Rank 1
answered on 15 Jul 2012, 11:32 PM
Just after posting the above, I thought I should try to set ApplicationBar.IsVisible = true; But I am getting the NullReferenceError. That is ApplicationBar is lost. Is this a bug?

I am using the latest internal build 2012.2.0713 version.
0
Accepted
Victor
Telerik team
answered on 16 Jul 2012, 09:21 AM
Hello Shantimohan,

Thanks for writing.
This turns out to be a bug in WP Silverlight framework. When you try to to open RadMessageBox, the RadWindow instance in the message box fails to open because it relies on a LayoutUpdated event that does fire while the OnBackKeyPress method is executing. You can workaround this by making sure that RadMessageBox show is called after OnBackKeyPress. This  can be done with Dispatcher.BeginInvoke().

Please write again if you need further assistance.

All the best,
Victor
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Shantimohan
Top achievements
Rank 1
answered on 16 Jul 2012, 11:15 PM
Despatcher.BeginInvoke(() => ... ); worked magically.

ThanQ...
Tags
MessageBox
Asked by
Shantimohan
Top achievements
Rank 1
Answers by
Shantimohan
Top achievements
Rank 1
Victor
Telerik team
Share this question
or