diff --git a/src/FluentAvalonia/Styling/Core/FluentAvaloniaTheme.axaml.cs b/src/FluentAvalonia/Styling/Core/FluentAvaloniaTheme.axaml.cs index 6a10600b..cd167333 100644 --- a/src/FluentAvalonia/Styling/Core/FluentAvaloniaTheme.axaml.cs +++ b/src/FluentAvalonia/Styling/Core/FluentAvaloniaTheme.axaml.cs @@ -1,14 +1,17 @@ using Avalonia; using Avalonia.Collections; using Avalonia.Controls; +using Avalonia.Controls.Presenters; using Avalonia.Layout; using Avalonia.Markup.Xaml; using Avalonia.Media; using Avalonia.Platform; using Avalonia.Styling; +using Avalonia.Threading; using FluentAvalonia.Interop; using FluentAvalonia.UI.Media; using System.Collections.Specialized; +using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -133,8 +136,20 @@ public Color? CustomAccentColor /// to get a consistent experience, at the (small) expense of breaking Fluent design principles. If your controls /// never use multi-line text, you'll never see the effect of this property. /// - public TextVerticalAlignmentOverride TextVerticalAlignmentOverrideBehavior { get; set; } = - TextVerticalAlignmentOverride.EnabledNonWindows; + public TextVerticalAlignmentOverride TextVerticalAlignmentOverrideBehavior + { + get => _textAlignmentOverride; + set + { + if (_textAlignmentOverride != value) + { + // NOTE: Attempting to downgrade this after startup will not + // remove the styles - this still requires an app restart + _textAlignmentOverride = value; + SetTextAlignmentOverrides(); + } + } + } public AvaloniaList MergedDictionaries { get; } @@ -393,7 +408,7 @@ private void SetTextAlignmentOverrides() // may get messed up b/c of the centered alignment var s3 = new Style(x => { - return x.OfType().Template().OfType().Child().OfType(); + return x.OfType().Template().OfType().Child().OfType(); }); s3.Setters.Add(new Setter(Layoutable.VerticalAlignmentProperty, VerticalAlignment.Center)); Add(s3); @@ -555,6 +570,9 @@ private void MergedDictionariesCollectionChanged(object sender, NotifyCollection private ResourceDictionary _accentColorsDictionary; private IPlatformSettings _platformSettings; + private TextVerticalAlignmentOverride _textAlignmentOverride = + TextVerticalAlignmentOverride.EnabledNonWindows; + public const string LightModeString = "Light"; public const string DarkModeString = "Dark"; public const string HighContrastModeString = "HighContrast";