Can focus rectangle be removed when tabbing to rounded button? #17479
-
(Windows - Avalonia 11.2.0) Using a nested style selector on 'focus-visible' I can change some properties, but 'CornerRadius' doesn't change the focus rectangle. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Given you are using Avalonia.Theme.Fluent (or Simple): The focus rectangle you see on the button, is not part of the button itself, but is coming from the The <ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Thickness x:Key="SystemControlFocusVisualMargin">0</Thickness>
<Thickness x:Key="SystemControlFocusVisualPrimaryThickness">2</Thickness>
<Thickness x:Key="SystemControlFocusVisualSecondaryThickness">1</Thickness>
<ControlTheme x:Key="{x:Type AdornerLayer}" TargetType="AdornerLayer">
<Setter Property="DefaultFocusAdorner">
<FocusAdornerTemplate>
<Border
Margin="{DynamicResource SystemControlFocusVisualMargin}"
BorderBrush="{DynamicResource SystemControlFocusVisualPrimaryBrush}"
BorderThickness="{DynamicResource SystemControlFocusVisualPrimaryThickness}">
<Border BorderBrush="{DynamicResource SystemControlFocusVisualSecondaryBrush}" BorderThickness="{DynamicResource SystemControlFocusVisualSecondaryThickness}" />
</Border>
</FocusAdornerTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary> Overwrite this default One way to change In your app.xaml file: <Application>
<Application.Resources>
<Thickness x:Key="SystemControlFocusVisualPrimaryThickness">0</Thickness>
</Application.Resources>
</Application> |
Beta Was this translation helpful? Give feedback.
A control (like the
Button
) has a propertyFocusAdorner
you can set -- if its not set you get theDefaultFocusAdorner
as mentioned above.Use something like:
Or override the default ControlTheme of the button which sets this property.