Skip to content

Commit

Permalink
Fixed issue with the designer crashing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Simnico99 committed Jan 8, 2024
1 parent bc7183c commit bea6fff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/MicaWPF.Core/Controls/MicaWindow/MicaWindowProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This software is distributed under the MIT license and its code is open-source and free for use, modification, and distribution.
// </copyright>

using System.ComponentModel;
using System.Windows;
using System.Windows.Shell;
using MicaWPF.Core.Enums;
Expand All @@ -13,7 +14,7 @@ public class MicaWindowProperty : MicaWindowStyle
{
public static readonly DependencyProperty CustomWindowChromeProperty = DependencyProperty.Register(nameof(CustomWindowChrome), typeof(WindowChrome), typeof(MicaWindowStyle));
public static readonly DependencyProperty TitleBarContentProperty = DependencyProperty.Register(nameof(TitleBarContent), typeof(UIElement), typeof(MicaWindowStyle));
public static readonly DependencyProperty UseAccentOnTitleBarAndBorderProperty = DependencyProperty.Register(nameof(UseAccentOnTitleBarAndBorder), typeof(bool), typeof(MicaWindowStyle), new UIPropertyMetadata(MicaWPFServiceUtility.AccentColorService.IsTitleBarAndWindowsBorderColored));
public static readonly DependencyProperty UseAccentOnTitleBarAndBorderProperty = DependencyProperty.Register(nameof(UseAccentOnTitleBarAndBorder), typeof(bool), typeof(MicaWindowStyle), new UIPropertyMetadata(MicaWPFServiceUtility.HasBeenInitialized ? MicaWPFServiceUtility.AccentColorService.IsTitleBarAndWindowsBorderColored : false));
public static readonly DependencyProperty ChangeTitleColorWhenInactiveProperty = DependencyProperty.Register(nameof(ChangeTitleColorWhenInactive), typeof(bool), typeof(MicaWindowStyle), new UIPropertyMetadata(true));
public static readonly DependencyProperty TitleBarHeightProperty = DependencyProperty.Register(nameof(TitleBarHeight), typeof(int), typeof(MicaWindowStyle), new UIPropertyMetadata(34));
public static readonly DependencyProperty TitleBarTypeProperty = DependencyProperty.Register(nameof(TitleBarType), typeof(TitleBarType), typeof(MicaWindowStyle), new UIPropertyMetadata(TitleBarType.WinUI));
Expand Down
18 changes: 14 additions & 4 deletions src/MicaWPF.Core/Services/MicaWPFServiceUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@ public sealed class MicaWPFServiceUtility
static MicaWPFServiceUtility()
{
// Warning the order is very important.
_currentNamespace ??= ServiceLocatorHelper.GetNamespace();
_themeDictionaryService ??= ServiceLocatorHelper.GetService<IThemeDictionaryService>();
_themeService ??= ServiceLocatorHelper.GetService<IThemeService>();
_accentColorService ??= ServiceLocatorHelper.GetService<IAccentColorService>();
try
{
_currentNamespace ??= ServiceLocatorHelper.GetNamespace();
_themeDictionaryService ??= ServiceLocatorHelper.GetService<IThemeDictionaryService>();
_themeService ??= ServiceLocatorHelper.GetService<IThemeService>();
_accentColorService ??= ServiceLocatorHelper.GetService<IAccentColorService>();
HasBeenInitialized = true;
}
catch
{
HasBeenInitialized = false;
}
}

public static bool HasBeenInitialized { get; }

/// <summary>
/// Gets or sets the Accent Color Service instance (WARNING: Sets should be done on application start).
/// </summary>
Expand Down

0 comments on commit bea6fff

Please sign in to comment.