public override void OnApplyTemplate() { base.OnApplyTemplate(); ButtonBase closeButton = GetTemplateChild(CloseButtonPartName) as ButtonBase; closeButton.Click += (sender, args) => { CloseMessageBoxCardAnimaton(); MessageBoxResultRoutedEventArge eventArgs = new MessageBoxResultRoutedEventArge(ReturnResultEvent, MessageBoxResult.No, this); this.RaiseEvent(eventArgs); }; if (IsShowOk) { ButtonBase okButton = GetTemplateChild(OkButtonPartName) as ButtonBase; okButton.Click += (sender, args) => { CloseMessageBoxCardAnimaton(); MessageBoxResultRoutedEventArge eventArgs = new MessageBoxResultRoutedEventArge(ReturnResultEvent, MessageBoxResult.OK, this); this.RaiseEvent(eventArgs); }; } if (IsShowCancel) { ButtonBase cancelButton = GetTemplateChild(CancelButtonPartName) as ButtonBase; cancelButton.Click += (sender, args) => { CloseMessageBoxCardAnimaton(); MessageBoxResultRoutedEventArge eventArgs = new MessageBoxResultRoutedEventArge(ReturnResultEvent, MessageBoxResult.Cancel, this); this.RaiseEvent(eventArgs); }; } if (IsShowYes) { ButtonBase yesButton = GetTemplateChild(YesButtonPartName) as ButtonBase; yesButton.Click += (sender, args) => { CloseMessageBoxCardAnimaton(); MessageBoxResultRoutedEventArge eventArgs = new MessageBoxResultRoutedEventArge(ReturnResultEvent, MessageBoxResult.Yes, this); this.RaiseEvent(eventArgs); }; } if (IsShowNo) { ButtonBase noButton = GetTemplateChild(NoButtonPartName) as ButtonBase; noButton.Click += (sender, args) => { CloseMessageBoxCardAnimaton(); MessageBoxResultRoutedEventArge eventArgs = new MessageBoxResultRoutedEventArge(ReturnResultEvent, MessageBoxResult.No, this); this.RaiseEvent(eventArgs); }; } }
private void Card_ReturnResult(object sender, MessageBoxResultRoutedEventArge e) { Storyboard unloadStoryboard = (Storyboard)this.Resources["UnLoadFadeUp"]; unloadStoryboard.Completed += (a, b) => { messageBoxPanel.Children.Remove(e.Card); DialogResult = true; }; rootGrid.BeginStoryboard(unloadStoryboard); MessageBoxResult = e.Result; }