public void viewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName.Equals("CurrentPopupView")) { if (null == viewModel.CurrentPopupView) { PopupControl.ShowPopup(false, viewModel.CurrentPopupView, false); } else if (viewModel.CommandParameter != null && (viewModel.CommandParameter.Equals("forgotPassword") || viewModel.CommandParameter.Equals("resetPassword")) || viewModel.CommandParameter.Equals("TemporaryPINSent")) { PopupControl.ShowPopup(true, viewModel.CurrentPopupView, false); } } else if (e.PropertyName.Equals("TemporaryPINAlreadySent")) { viewModel.CurrentPopupView = new SaveNotificationPopup("Please check your email. Your temporary password/PIN has been sent to your email.\nClick on Reset Password? button in the login screen to reset password using the temporary password/PIN provided."); } else if (e.PropertyName.Equals("InvalidUser")) { loginWarning.Visibility = Visibility.Visible; } else if (e.PropertyName.Equals("LogoutUser")) { loginWarning.Visibility = Visibility.Collapsed; } UserNameFocus(); }
public void viewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName.Equals("CurrentPopupView")) { if (null == viewModel.CurrentPopupView) { this.GridCustomers.IsEnabled = true; this.userInfoPanel.Opacity = this.GridCustomers.Opacity = this.MainTabControl.Opacity = this.CancelButton.Opacity = this.SaveButton.Opacity = this.DeleteButton.Opacity = this.SearchPanel.Opacity = 1; this.Opacity = 1; PopupControl.ShowPopup(false, viewModel.CurrentPopupView, false); } else { this.GridCustomers.IsEnabled = false; this.userInfoPanel.Opacity = this.GridCustomers.Opacity = this.MainTabControl.Opacity = this.CancelButton.Opacity = this.SaveButton.Opacity = this.DeleteButton.Opacity = this.SearchPanel.Opacity = 0.5; PopupControl.ShowPopup(true, viewModel.CurrentPopupView, false); } } else if (e.PropertyName.Equals("SavedCustomer")) { viewModel.CurrentPopupView = new SaveNotificationPopup("Details are successfully saved."); } else if (e.PropertyName.Equals("EmptyFields")) { viewModel.CurrentPopupView = new WarningErrorNotificationPopup("Please fill the required fields."); } else if (e.PropertyName.Equals("ReadyToSave")) { SaveDetails(); } else if (e.PropertyName.Equals("PasswordChanged")) { viewModel.CurrentPopupView = new SaveNotificationPopup("Password changed successfully."); } if (e.PropertyName.Equals("NonAdmin") || viewModel.CurrentPopupView == null) { if (viewModel.CurrentAppUser != null) { DisableControlForNonAdmin(viewModel.CurrentAppUser.IsAdmin); } } }
/// <summary> /// Shows a simple full screen popup /// </summary> /// <param name="content">Content you want to be presented inside the popup. Simply use typeof(YourUserControl)</param> /// <param name="Host_Id">Id of the control that will host the new popup</param> /// <param name="OpenNewIfExists">Allows to open more than one popup with the same content</param> /// <param name="ShowAnimationMode">Animation mode of showing the popup</param> /// <param name="HideAnimationMode">Animation mode of hiding the popup</param> /// <param name="Margin">Content padding from the sides</param> /// <param name="ShowAnimDuration">Show animation duration</param> /// <param name="HideAnimDuration">Hide animation duration</param> /// <param name="args">Arguments needed on the Content ctor</param> /// <returns></returns> public static Guid ShowPopupControl(Type content, string Host_Id = null, bool OpenNewIfExists = true, PopupControlAnimationKind ShowAnimationMode = PopupControlAnimationKind.FadeIn, PopupControlAnimationKind HideAnimationMode = PopupControlAnimationKind.FadeOut, Thickness?Margin = null, Duration?ShowAnimDuration = null, Duration?HideAnimDuration = null, params object[] args) { PopupPresenterHost Host = null; try { if (Host_Id == null) { Host = _hosts.Any() ? _hosts.FirstOrDefault() : throw new Exception("Mo Hosts found or the host disposed."); } else { Host = _hosts.Any() ? _hosts.First(x => x.Id == Host_Id) : throw new Exception("Mo Hosts found or the host disposed."); } var testthreadaccess = Host.Id; } catch (Exception ex) { if (ex.Message.Contains("0x8001010E")) { foreach (var item in _hosts) { try { if (item.Id is null || item.Id is string str) { if (Host_Id == null) { Host = item; } else if (item.Id == Host_Id) { Host = item; } } } catch { } } } } if (Host.Children.Any(x => x is PopupControl pop && pop.PopupContentType == content)) { if (!OpenNewIfExists) { throw new Exception("An existing popup of this type is currently open."); } } var p = new PopupControl(content, args) { ShowAnimation = ShowAnimationMode, HideAnimation = HideAnimationMode }; if (Margin.HasValue) { p.ContentMargin = Margin.Value; } if (ShowAnimDuration.HasValue) { p.ShowAnimationDuration = ShowAnimDuration.Value; } if (HideAnimDuration.HasValue) { p.HideAnimationDuration = HideAnimDuration.Value; } Host.Children.Add(p); p.ShowPopup(); return(p.Identifier); }