public void Hide(ContentDialogBaseResult result) { if (_popupHost == null || !_popupHost.IsOpen) { return; } _lastHide = Environment.TickCount; _result = result; _popupHost.IsOpen = false; }
public IAsyncOperation <ContentDialogBaseResult> ShowAsync() { return(AsyncInfo.Run(async(token) => { Margin = new Thickness(); if (DataContext is INavigable navigable) { navigable.NavigationService = new ContentDialogNavigationService(this); } var previous = _callback; _result = ContentDialogBaseResult.None; _callback = new TaskCompletionSource <ContentDialogBaseResult>(); _applicationView = ApplicationView.GetForCurrentView(); OnVisibleBoundsChanged(_applicationView, null); if (_popupHost == null) { _popupHost = new Popup(); _popupHost.Child = this; _popupHost.Loading += PopupHost_Loading; _popupHost.Loaded += PopupHostLoaded; _popupHost.Opened += PopupHost_Opened; _popupHost.Closed += PopupHost_Closed; this.Unloaded += PopupHost_Unloaded; } // Cool down if (previous != null) { await previous.Task; } //if (Environment.TickCount - _lastHide < 500) //{ // await Task.Delay(200); //} _popupHost.IsOpen = true; return await _callback.Task; })); }