@ -53,7 +53,7 @@ namespace Avalonia
/// <inheritdoc cref="ThemeVariantScope.ActualThemeVariantProperty" />
/// <inheritdoc cref="ThemeVariantScope.ActualThemeVariantProperty" />
public static readonly StyledProperty < ThemeVariant > ActualThemeVariantProperty =
public static readonly StyledProperty < ThemeVariant > ActualThemeVariantProperty =
ThemeVariantScope . ActualThemeVariantProperty . AddOwner < Application > ( ) ;
ThemeVariantScope . ActualThemeVariantProperty . AddOwner < Application > ( ) ;
/// <inheritdoc cref="ThemeVariantScope.RequestedThemeVariantProperty" />
/// <inheritdoc cref="ThemeVariantScope.RequestedThemeVariantProperty" />
public static readonly StyledProperty < ThemeVariant ? > RequestedThemeVariantProperty =
public static readonly StyledProperty < ThemeVariant ? > RequestedThemeVariantProperty =
ThemeVariantScope . RequestedThemeVariantProperty . AddOwner < Application > ( ) ;
ThemeVariantScope . RequestedThemeVariantProperty . AddOwner < Application > ( ) ;
@ -91,7 +91,7 @@ namespace Avalonia
get = > GetValue ( RequestedThemeVariantProperty ) ;
get = > GetValue ( RequestedThemeVariantProperty ) ;
set = > SetValue ( RequestedThemeVariantProperty , value ) ;
set = > SetValue ( RequestedThemeVariantProperty , value ) ;
}
}
/// <inheritdoc />
/// <inheritdoc />
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1031", Justification = "This property is supposed to be a styled readonly property.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1031", Justification = "This property is supposed to be a styled readonly property.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1030", Justification = "False positive.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1030", Justification = "False positive.")]
@ -201,7 +201,7 @@ namespace Avalonia
/// as specific top levels might have different settings set-up.
/// as specific top levels might have different settings set-up.
/// </remarks>
/// </remarks>
public IPlatformSettings ? PlatformSettings = > this . TryGetFeature < IPlatformSettings > ( ) ;
public IPlatformSettings ? PlatformSettings = > this . TryGetFeature < IPlatformSettings > ( ) ;
event Action < IReadOnlyList < IStyle > > ? IGlobalStyles . GlobalStylesAdded
event Action < IReadOnlyList < IStyle > > ? IGlobalStyles . GlobalStylesAdded
{
{
add = > _ stylesAdded + = value ;
add = > _ stylesAdded + = value ;
@ -218,7 +218,7 @@ namespace Avalonia
/// Initializes the application by loading XAML etc.
/// Initializes the application by loading XAML etc.
/// </summary>
/// </summary>
public virtual void Initialize ( ) { }
public virtual void Initialize ( ) { }
/// <inheritdoc/>
/// <inheritdoc/>
public bool TryGetResource ( object key , ThemeVariant ? theme , out object? value )
public bool TryGetResource ( object key , ThemeVariant ? theme , out object? value )
{
{
@ -262,7 +262,7 @@ namespace Avalonia
. Bind < IGlobalStyles > ( ) . ToConstant ( this )
. Bind < IGlobalStyles > ( ) . ToConstant ( this )
. Bind < IThemeVariantHost > ( ) . ToConstant ( this )
. Bind < IThemeVariantHost > ( ) . ToConstant ( this )
. Bind < IInputManager > ( ) . ToConstant ( InputManager )
. Bind < IInputManager > ( ) . ToConstant ( InputManager )
. Bind < IToolTipService > ( ) . ToConstant ( new ToolTipService ( InputManager ) )
. Bind < IToolTipService > ( ) . ToConstant ( new ToolTipService ( InputManager ) )
. Bind < IKeyboardNavigationHandler > ( ) . ToTransient < KeyboardNavigationHandler > ( )
. Bind < IKeyboardNavigationHandler > ( ) . ToTransient < KeyboardNavigationHandler > ( )
. Bind < IDragDropDevice > ( ) . ToConstant ( DragDropDevice . Instance ) ;
. Bind < IDragDropDevice > ( ) . ToConstant ( DragDropDevice . Instance ) ;
@ -330,20 +330,28 @@ namespace Avalonia
if ( change . Property = = RequestedThemeVariantProperty )
if ( change . Property = = RequestedThemeVariantProperty )
{
{
if ( change . GetNewValue < ThemeVariant > ( ) is { } themeVariant & & themeVariant ! = ThemeVariant . Default )
if ( change . GetNewValue < ThemeVariant > ( ) is { } themeVariant )
SetValue ( ActualThemeVariantProperty , themeVariant ) ;
{
else
if ( themeVariant = = ThemeVariant . Default )
ClearValue ( ActualThemeVariantProperty ) ;
{
ClearValue ( ActualThemeVariantProperty ) ;
}
else
{
SetValue ( ActualThemeVariantProperty , themeVariant ) ;
}
}
}
}
else if ( change . Property = = ActualThemeVariantProperty )
else if ( change . Property = = ActualThemeVariantProperty )
{
{
ActualThemeVariantChanged ? . Invoke ( this , EventArgs . Empty ) ;
ActualThemeVariantChanged ? . Invoke ( this , EventArgs . Empty ) ;
}
}
}
}
private void OnColorValuesChanged ( object? sender , PlatformColorValues e )
private void OnColorValuesChanged ( object? sender , PlatformColorValues e )
{
{
SetValue ( ActualThemeVariantProperty , ( ThemeVariant ) e . ThemeVariant , BindingPriority . Template ) ;
if ( ( RequestedThemeVariant ? ? ThemeVariant . Default ) = = ThemeVariant . Default )
SetValue ( ActualThemeVariantProperty , ( ThemeVariant ) e . ThemeVariant ) ;
}
}
}
}
}
}