Reputation: 11492
I have an automatic-lock functionality in my Silverlight app that needs to lock the screen after a certain period. The problem is that open dialogs remains open even if the app is locked.
How do I close these dialogs programatically?
Upvotes: 1
Views: 651
Reputation: 5987
you should add this like :
dialog.DialogResult = false;
dialog.Close();
Upvotes: 1
Reputation: 11492
I use the following code snippet to close open dialogs in my silverlight app.
UIElement ui = App.Current.RootVisual;
foreach (var popup in VisualTreeHelper.GetOpenPopups())
{
if (popup != null)
{
System.Windows.Controls.ChildWindow dialog = popup.Child as System.Windows.Controls.ChildWindow;
if (dialog != null)
{
dialog.DialogResult = false;
dialog.Close();
}
}
}
This only works in Silverlight 4 or newer.
Upvotes: 0