0

I am having a problem with the Monitored Test cases "Use of Back Button". I always get the error message

[ERROR]: Pressing the Back button on page MainPage.xaml does not close the dialog box

I'm pretty sure, that I close all Dialogs, when the Back-Button is pressed. I even null them out, after returning a valid DialogResult.

Are there eventually any Controls(I only use standard Controls) that are classified as Dialog, like ContextMenus or other Controls?

And how can I know, which Dialog is meant? Are there any protocol files or something, that tells me in detail, how the test was passed? Output Windows or something else in Visual Studio 2010?

William Melani
  • 4,270
  • 1
  • 21
  • 44
awsomedevsigner
  • 150
  • 1
  • 7
  • 1
    Are you talking about the MessageBox? code might be useful to explain. – William Melani Jan 04 '12 at 20:29
  • Do you use the 'Popup' control somewhere? – Kevin Gosse Jan 04 '12 at 21:14
  • Hi, no I use a Child Window and open it through a ViewModel. The child window is opened, and I set a property on the ViewModel to indicate, that a Dialog was opened. In MainPage.xaml I override the OnBackKeyPress Method,cancel the event, and Fire an event on the ViewModel, which causes the ChildWindow to close by returning a valid DialogResult. Afterwards I set the CurrentDialog property to null. But the test still says, that I have dialogs open, and that the dialogs don't close when hitting the hardware-back-button. – awsomedevsigner Jan 04 '12 at 21:25
  • 1
    Here is the code from OnBackKeyPress: `code` protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { var currentViewModel = (SkyDriveViewModel)Resources["ViewModel"]; //close open dialog if (currentViewModel.IsDialogOpen) { currentViewModel.OnWindowClosed(); currentViewModel.IsDialogOpen = false; currentViewModel.CurrentDialog = null; e.Cancel = true; } base.OnBackKeyPress(e); }`code` – awsomedevsigner Jan 04 '12 at 21:29
  • And here the code from within the ChildWindows:`code`void model_CloseWindowEvent(object sender, EventArgs e) { SkyDriveViewModel model = App.ViewModelForApp as SkyDriveViewModel; model.IsDialogOpen = false; this.DialogResult = true; } – awsomedevsigner Jan 04 '12 at 21:31
  • Initialization of the dialog in the ViewModel `MoveFileDialog dlg = new MoveFileDialog(); //Set the id of the file to move. dlg.FileMoveId = values.FileId; dlg.CopyOrMoveCaption = "copy file to"; dlg.OkButtonCaption = "Copy"; dlg.CopyOrMoveFiles = "copy"; dlg.ParentDirectory = values.FileParentId; ApplicationBarEnabled = false; AppBarCommand.RaiseCanExecuteChanged(); IsDialogOpen = true; dlg.Show();` – awsomedevsigner Jan 04 '12 at 21:34
  • I posted the question also here, and I have published more code there [http://forums.create.msdn.com/forums/p/97842/583498.aspx#583498] – awsomedevsigner Jan 04 '12 at 23:03

1 Answers1

0

For anyone else coming across this question, there is an answer in the version of this question posted on the MSDN forums:
http://forums.create.msdn.com/forums/p/97842/583498.aspx#583498

(There was a ChildWindow which needed to be explicitly closed.)

Matt Lacey
  • 65,560
  • 11
  • 91
  • 143