Windows phone 7 [错误]:按page MainPage.xaml上的后退按钮不会关闭对话框

Windows phone 7 [错误]:按page MainPage.xaml上的后退按钮不会关闭对话框,windows-phone-7,navigation,marketplace,childwindow,Windows Phone 7,Navigation,Marketplace,Childwindow,我对监控的测试用例“使用后退按钮”有问题。我总是收到错误信息 [ERROR]: Pressing the Back button on page MainPage.xaml does not close the dialog box 我很确定,当按下后退按钮时,我会关闭所有的对话框。我甚至把它们剔除了, 返回有效的对话框结果后 最终是否有任何控件(我只使用标准控件)被归类为对话框,如上下文菜单 或其他控件 我怎么知道,哪个对话框是什么意思?有没有协议文件或其他什么详细告诉我的, 考试是怎么通过

我对监控的测试用例“使用后退按钮”有问题。我总是收到错误信息

[ERROR]: Pressing the Back button on page MainPage.xaml does not close the dialog box
我很确定,当按下后退按钮时,我会关闭所有的
对话框。我甚至把它们剔除了,
返回有效的
对话框结果后

最终是否有任何
控件
(我只使用标准
控件
)被归类为
对话框
,如
上下文菜单
或其他
控件

我怎么知道,哪个
对话框是什么意思?有没有协议文件或其他什么详细告诉我的,

考试是怎么通过的?Visual Studio 2010中的输出窗口或其他内容?

对于遇到此问题的其他人,MSDN论坛上发布的此问题版本中有一个答案:


(有一个ChildWindow需要显式关闭。)

您是说MessageBox吗?代码可能有助于解释。您是否在某处使用“弹出”控件?嗨,不,我使用子窗口并通过ViewModel打开它。子窗口已打开,我在ViewModel上设置了一个属性,以指示对话框已打开。在MainPage.xaml中,我重写OnBackKeyPress方法,取消事件,并在ViewModel上触发一个事件,这会通过返回有效的DialogResult导致ChildWindow关闭。之后,我将CurrentDialog属性设置为null。但是测试仍然显示,我打开了对话框,当按下hardware-back按钮时对话框不会关闭。以下是OnBackKeyPress的代码:
code
protectedoverride void OnBackKeyPress(System.ComponentModel.CancelEventArgs e){var currentViewModel=(SkyDriveViewModel)Resources[“ViewModel”];//如果(currentViewModel.IsDialogOpen){currentViewModel.OnWindowClosed();currentViewModel.IsDialogOpen=false;currentViewModel.CurrentDialog=null;e.Cancel=true;}base.OnBackKeyPress(e)则关闭打开的对话框}
code
这里是子窗口中的代码:
code
void model\u CloseWindowEvent(对象发送方,EventArgs e){SkyDriveViewModel=App.ViewModelForApp as SkyDriveViewModel;model.IsDialogOpen=false;this.DialogResult=true;}