private void OnThemeChanged(WindowButtonCommands o, AvaloniaPropertyChangedEventArgs e) { if (LightCloseButtonStyle == null || LightMaxButtonStyle == null || LightMinButtonStyle == null || DarkCloseButtonStyle == null || DarkMaxButtonStyle == null || DarkMinButtonStyle == null) { return; } if (e.NewValue is WindowCommandTheme) { WindowCommandTheme windowCommandTheme = (WindowCommandTheme)e.NewValue; close.Styles.Remove(LightCloseButtonStyle); close.Styles.Remove(DarkCloseButtonStyle); max.Styles.Remove(LightMaxButtonStyle); max.Styles.Remove(DarkMaxButtonStyle); min.Styles.Remove(LightMinButtonStyle); min.Styles.Remove(DarkMinButtonStyle); switch (windowCommandTheme) { case WindowCommandTheme.Light: close.Styles.Add(LightCloseButtonStyle); max.Styles.Add(LightMaxButtonStyle); min.Styles.Add(LightMinButtonStyle); break; case WindowCommandTheme.Dark: close.Styles.Add(DarkCloseButtonStyle); max.Styles.Add(DarkMaxButtonStyle); min.Styles.Add(DarkMinButtonStyle); break; } } }
/// <inheritdoc/> protected override void OnTemplateApplied(TemplateAppliedEventArgs e) { base.OnTemplateApplied(e); LeftWindowCommandsPresenter = e.NameScope.Find <ContentPresenter>(PART_LeftWindowCommands); RightWindowCommandsPresenter = e.NameScope.Find <ContentPresenter>(PART_RightWindowCommands); WindowButtonCommandsPresenter = e.NameScope.Find <ContentPresenter>(PART_WindowButtonCommands); if (LeftWindowCommands == null) { LeftWindowCommands = new WindowCommands(); } if (RightWindowCommands == null) { RightWindowCommands = new WindowCommands(); } if (WindowButtonCommands == null) { WindowButtonCommands = new WindowButtonCommands(); } LeftWindowCommands.ParentWindow = this; RightWindowCommands.ParentWindow = this; WindowButtonCommands.ParentWindow = this; overlayBox = e.NameScope.Find <Grid>(PART_OverlayBox); metroActiveDialogContainer = e.NameScope.Find <Grid>(PART_MetroActiveDialogContainer); metroInactiveDialogContainer = e.NameScope.Find <Grid>(PART_MetroInactiveDialogsContainer); flyoutModal = e.NameScope.Find <Rectangle>(PART_FlyoutModal); flyoutModal.PointerPressed += FlyoutsPreviewMouseDown; //flyoutModal.MouseDown += FlyoutsPreviewMouseDown; this.PointerPressed += FlyoutsPreviewMouseDown; _icon = e.NameScope.Find <ContentControl>(PART_Icon); _titleBar = e.NameScope.Find <ContentControl>(PART_TitleBar); _titleBarBackground = e.NameScope.Find <Rectangle>(PART_WindowTitleBackground); _windowTitleThumb = e.NameScope.Find <Thumb>(PART_WindowTitleThumb); _flyoutModalDragMoveThumb = e.NameScope.Find <Thumb>(PART_FlyoutModalDragMoveThumb); SetVisibiltyForAllTitleElements(); var metroContentControl = e.NameScope.Find <MetroContentControl>(PART_Content); if (metroContentControl != null) { if (Design.IsDesignMode == false) { metroContentControl.TransitionCompleted += (sender, args) => this.RaiseEvent(new RoutedEventArgs(WindowTransitionCompletedEvent)); } } _topHorizontalGrip = e.NameScope.Find <Grid>(PART_TopHorizontalGrip); _bottomHorizontalGrip = e.NameScope.Find <Grid>(PART_BottomHorizontalGrip); _leftVerticalGrip = e.NameScope.Find <Grid>(PART_LeftVerticalGrip); _rightVerticalGrip = e.NameScope.Find <Grid>(PART_RightVerticalGrip); _topLeftGrip = e.NameScope.Find <Grid>(PART_TopLeftGrip); _bottomLeftGrip = e.NameScope.Find <Grid>(PART_BottomLeftGrip); _topRightGrip = e.NameScope.Find <Grid>(PART_TopRightGrip); _bottomRightGrip = e.NameScope.Find <Grid>(PART_BottomRightGrip); }