
I would like to discard the rounded corners throughout my entire application. How can I override all the radius styles so I don't have to manually set each and ever control?
I would like to discard the rounded corners throughout my entire application. How can I override all the radius styles so I don't have to manually set each and ever control?
I ended up adding the following style which fixed my buttons. I'm not sure if this is the best way but I have it working for my buttons now:
<Style Selector="Button">
<Setter Property="CornerRadius" Value="2" />
</Style>
[Modified 8 months ago]
All of our themes use configurable resources to control corner radii. You could configure each control like you've done, but there are two other options as well.
One option is to override out theme assets (like "ButtonCornerRadius") to specify zero for the corner radius. More details on that here:
https://www.actiprosoftware.com/docs/controls/avalonia/themes/theme-assets#overriding-assets
For instance, the following could be used to override the corner radius of a button:
<Application ... xmlns:actipro="http://schemas.actiprosoftware.com/avaloniaui">
<Application.Resources>
<ResourceDictionary>
<CornerRadius x:Key="{actipro:ThemeResourceKey ButtonCornerRadius}">0</CornerRadius>
</ResourceDictionary>
</Application.Resources>
</Application>
The Sample Browser application has a Theme Resource Browser you can use to search for all the assets with CornerRadius in the name.
Since you want to change everyhing to square, another option would be to create a custom ThemeGenerator that can override the corner radius values. More details on that here:
Specifically, you would override the GetCornerRadiusResource method to return zero for every resource. This approach would ensure that even if we add new corner radius theme assets in the future your custom theme generator would always set those to zero. Do note that there is a resource called FullRoundCornerRadius that is always intended to represent a circle and is used by controls like Avatar. You might not want to change that one, and you can always use the ThemeResourceKind enum passed to GetCornerRadiusResource to be more selective about which resources you default to zero.
Please log in to a validated account to post comments.