diff --git a/source/iNKORE.UI.WPF.Modern.Controls/Controls/MessageBox/MessageBox.cs b/source/iNKORE.UI.WPF.Modern.Controls/Controls/MessageBox/MessageBox.cs index e174b091..08c317e1 100644 --- a/source/iNKORE.UI.WPF.Modern.Controls/Controls/MessageBox/MessageBox.cs +++ b/source/iNKORE.UI.WPF.Modern.Controls/Controls/MessageBox/MessageBox.cs @@ -13,6 +13,7 @@ using System.Windows.Controls; using System.Windows.Input; using System.Windows.Interop; +using System.Windows.Media; using static iNKORE.UI.WPF.Modern.Controls.LocalizedDialogCommands; namespace iNKORE.UI.WPF.Modern.Controls @@ -27,10 +28,11 @@ public MessageBoxResult Result - private Button OKButton { get; set; } - private Button YesButton { get; set; } - private Button NoButton { get; set; } - private Button CancelButton { get; set; } + public Button OKButton { get; private set; } + public Button YesButton { get; private set; } + public Button NoButton { get; private set; } + public Button CancelButton { get; private set; } + public Border Border_UpperBackground { get; private set; } public static BackdropType DefaultBackdropType { get; set; } = BackdropType.None; @@ -39,6 +41,8 @@ static MessageBox() DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageBox), new FrameworkPropertyMetadata(typeof(MessageBox))); } + public static readonly DependencyPropertyDescriptor SystemBackdropTypeProperty_Descriptor = DependencyPropertyDescriptor.FromProperty(WindowHelper.SystemBackdropTypeProperty, typeof(MessageBox)); + public MessageBox() { SetValue(TemplateSettingsPropertyKey, new MessageBoxTemplateSettings()); @@ -46,6 +50,27 @@ public MessageBox() ThemeManager.AddActualThemeChangedHandler(this, handler); Loaded += On_Loaded; + + SystemBackdropTypeProperty_Descriptor.AddValueChanged(this, SystemBackdropTypeProperty_ValueChanged); + } + + private void SystemBackdropTypeProperty_ValueChanged(object sender, EventArgs e) + { + var backdrop = WindowHelper.GetSystemBackdropType(this); + + if(this.ReadLocalValue(BackgroundProperty) == DependencyProperty.UnsetValue) + { + if (backdrop == BackdropType.None || !backdrop.IsSupported()) + { + this.SetResourceReference(BackgroundProperty, ThemeKeys.ContentDialogBackgroundKey); + Border_UpperBackground?.SetResourceReference(BackgroundProperty, ThemeKeys.ContentDialogTopOverlayKey); + } + else + { + this.Background = Brushes.Transparent; + Border_UpperBackground?.SetResourceReference(BackgroundProperty, ThemeKeys.LayerOnAcrylicFillColorDefaultBrushKey); + } + } } #region Caption @@ -449,9 +474,9 @@ public MessageBoxTemplateSettings TemplateSettings public event TypedEventHandler Opened; - public event TypedEventHandler Closing; + public new event TypedEventHandler Closing; - public event TypedEventHandler Closed; + public new event TypedEventHandler Closed; public event TypedEventHandler OKButtonClick; @@ -507,6 +532,7 @@ public override void OnApplyTemplate() YesButton = GetTemplateChild(nameof(YesButton)) as Button; NoButton = GetTemplateChild(nameof(NoButton)) as Button; CancelButton = GetTemplateChild(nameof(CancelButton)) as Button; + Border_UpperBackground = GetTemplateChild(nameof(Border_UpperBackground)) as Border; if (OKButton != null) { @@ -760,6 +786,8 @@ private void On_Loaded(object sender, RoutedEventArgs e) { WindowHelper.SetSystemBackdropType(this, DefaultBackdropType); } + + SystemBackdropTypeProperty_ValueChanged(sender, e); } private static void TryExecuteCommand(ICommand command, object parameter) diff --git a/source/iNKORE.UI.WPF.Modern.Controls/Controls/MessageBox/MessageBox.xaml b/source/iNKORE.UI.WPF.Modern.Controls/Controls/MessageBox/MessageBox.xaml index 9644db19..8074f171 100644 --- a/source/iNKORE.UI.WPF.Modern.Controls/Controls/MessageBox/MessageBox.xaml +++ b/source/iNKORE.UI.WPF.Modern.Controls/Controls/MessageBox/MessageBox.xaml @@ -284,9 +284,9 @@ - + @@ -296,9 +296,9 @@ - + diff --git a/source/iNKORE.UI.WPF.Modern/Helpers/ColorsHelper.cs b/source/iNKORE.UI.WPF.Modern/Helpers/ColorsHelper.cs index 085bb81f..e9b7b39a 100644 --- a/source/iNKORE.UI.WPF.Modern/Helpers/ColorsHelper.cs +++ b/source/iNKORE.UI.WPF.Modern/Helpers/ColorsHelper.cs @@ -22,7 +22,7 @@ namespace iNKORE.UI.WPF.Modern.Helpers { - internal class ColorsHelper : DispatcherObject + public class ColorsHelper : DispatcherObject { private const string AccentKey = "SystemAccentColor"; private const string AccentDark1Key = "SystemAccentColorDark1"; diff --git a/source/samples/WpfApp1/MainWindow.xaml b/source/samples/WpfApp1/MainWindow.xaml index ad58b5c0..56ee269b 100644 --- a/source/samples/WpfApp1/MainWindow.xaml +++ b/source/samples/WpfApp1/MainWindow.xaml @@ -11,7 +11,7 @@ ui:TitleBar.ExtendViewIntoTitleBar="False" ui:WindowHelper.SystemBackdropType="Acrylic" ui:WindowHelper.UseModernWindowStyle="True" ui:TitleBar.IsBackButtonVisible="False" ui:ThemeManager.RequestedTheme="Light" - ui:WindowHelper.CornerStyle="DoNotRound" Background="{x:Null}" Loaded="Window_Loaded"> + ui:WindowHelper.CornerStyle="DoNotRound" Background="Red" Loaded="Window_Loaded">