private static void OnCanDialogFlyout(object sender, CanExecuteRoutedEventArgs e) { DialogStacks dialogstacks = (DialogStacks)sender; e.CanExecute = dialogstacks.Items.Count > 0; e.Handled = true; }
public void Close() { if (this.ParentDialogStacks != null && this.ParentDialogStacks.Items.Contains(this) && object.ReferenceEquals(this.ParentDialogStacks.Items[this.ParentDialogStacks.Items.Count - 1], this)) { this.ParentDialogStacks.CloseDialog(); } else { FrameworkElement fe = this.Parent as FrameworkElement; while (fe != null && fe.GetType() != typeof(Window)) { if (fe.GetType() == typeof(DialogStacks)) { DialogStacks dialogstack = fe as DialogStacks; if (dialogstack.Items.Contains(this) && object.ReferenceEquals(dialogstack.Items[dialogstack.Items.Count - 1], this)) { dialogstack.CloseDialog(); return; } } fe = fe.Parent as FrameworkElement; } } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); _flyoutStacks = GetTemplateChild(PART_FLYOUTSTACKS) as FlyoutStacks; _dialogStacks = GetTemplateChild(PART_DIALOGSTACKS) as DialogStacks; if (_flyoutStacks == null && _dialogStacks == null) { throw new Exception(); } }