in my Popup windows (contains game options control) I have "Reset HighScores" Button. Button fire a MessageDialog with a TextBlock "Are you sure that ..." and two Buttons "Yes" and "No". However, when MessageDialog opens, Popup closes. Do you know how to make popup still alive?
Asked
Active
Viewed 685 times
2 Answers
4
I was able to get around this using an Action
delegate as a callback for when the MessageDialog
is closed.
The key is to call the Action after an await
on MessageDialog
's ShowAsync
in an async
function.
Another key is to Close and Open your popup to get the IsLightDismissEnabled
to actually take hold.
XAML:
<Popup
IsLightDismissEnabled="{Binding IsLightDismiss, Mode=TwoWay}"
IsOpen="{Binding IsPopupOpen, Mode=TwoWay}">
ViewModel:
private bool isPopupOpen;
public bool IsPopupOpen
{
get { return this.isPopupOpen; }
set { this.SetProperty(ref this.isPopupOpen, value); }
}
private bool isLightDismiss;
public bool IsLightDismiss
{
get { return this.isLightDismiss; }
set { this.SetProperty(ref this.isLightDismiss, value); }
}
protected void ShowDialog()
{
this.IsLightDismiss = false;
this.IsPopupOpen = false;
this.IsPopupOpen = true;
Action showPopup = () => {
this.IsLightDismiss = true;
this.IsPopupOpen = false;
this.IsPopupOpen = true;
};
ShowMessageDialog("message", "title", showPopup);
}
private async void ShowMessageDialog(string message, string title, Action callback)
{
var _messageDialog = new MessageDialog(message, title);
await _messageDialog.ShowAsync();
callback();
}

dannyfritz
- 396
- 5
- 12
1
set your Popup
's IsLightDismissEnabled
property to false
to achieve that.
popup.IsLightDismissEnabled = false;

Mayank
- 8,777
- 4
- 35
- 60
-
you should add `popup.LostFocus` event handler then, in event handler you can make sure it stays open – Mayank Nov 10 '12 at 21:10