Windows phone 8.1 中按下 home 键时如何防止 ContentDialog 关闭
How to prevent the ContentDialog from closing when home key is pressed in Windows phone 8.1
Folowing is my code which i am using to prevent losing when back key
is pressed, But it is also blocking the "Yes" and "No" buttons of
content dialog. What could be the reason?**
dialog = new ContentDialog()
{
Title = "One basta found",
//RequestedTheme = ElementTheme.Dark,
//FullSizeDesired = true,
MaxWidth = this.ActualWidth // Required for Mobile!
};
// Setup Content
var panel = new StackPanel();
panel.Children.Add(new TextBlock
{
Text = file.Name+" is found. Do you want to add it?",
TextWrapping = TextWrapping.Wrap,
});
dialog.Content = panel;
// Add Buttons
dialog.PrimaryButtonText = "Yes";
dialog.IsPrimaryButtonEnabled = true;
dialog.Closing += ContentDialog_Closing;
void ContentDialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
{
args.Cancel = true;
}
如果我理解正确,您希望在从主屏幕返回应用程序后打开内容对话框。
也许你应该尝试一些小的解决方法。如果内容对话框打开,在 onNavigatedFrom 中保存信息,并在 onNavigatedTo 中检查并再次显示内容对话框。
没有 运行 visual studio:
override OnNavigatedTo(...){
if(this.contentDialogShouldBeOpen){
OpenContentDialog();
}
}
override OnNavigatedFrom(...){
this.contentDialogShouldBeOpen = isContentDialogOpen;
}
Folowing is my code which i am using to prevent losing when back key is pressed, But it is also blocking the "Yes" and "No" buttons of content dialog. What could be the reason?**
dialog = new ContentDialog()
{
Title = "One basta found",
//RequestedTheme = ElementTheme.Dark,
//FullSizeDesired = true,
MaxWidth = this.ActualWidth // Required for Mobile!
};
// Setup Content
var panel = new StackPanel();
panel.Children.Add(new TextBlock
{
Text = file.Name+" is found. Do you want to add it?",
TextWrapping = TextWrapping.Wrap,
});
dialog.Content = panel;
// Add Buttons
dialog.PrimaryButtonText = "Yes";
dialog.IsPrimaryButtonEnabled = true;
dialog.Closing += ContentDialog_Closing;
void ContentDialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
{
args.Cancel = true;
}
如果我理解正确,您希望在从主屏幕返回应用程序后打开内容对话框。 也许你应该尝试一些小的解决方法。如果内容对话框打开,在 onNavigatedFrom 中保存信息,并在 onNavigatedTo 中检查并再次显示内容对话框。
没有 运行 visual studio:
override OnNavigatedTo(...){
if(this.contentDialogShouldBeOpen){
OpenContentDialog();
}
}
override OnNavigatedFrom(...){
this.contentDialogShouldBeOpen = isContentDialogOpen;
}