Xamarin.Forms
Xamarin.Forms copied to clipboard
[Bug] Style inheritance not working
Description
The inherited style does not seem to be applied: the corner radius of the button is clearly 6, while 50 is set deeper in the inheritance hierarchy. I just wanted to know whether this is a bug, or whether I have misunderstood how style inheritance should work.
Application.xaml
<System:Int32 x:Key="DefaultCornerRadius">6</System:Int32>
<Style x:Key="BaseButtonStyle"
TargetType="Button">
<Setter Property="BorderRadius"
Value="{StaticResource DefaultCornerRadius}" />
<Setter Property="CornerRadius"
Value="{StaticResource DefaultCornerRadius}" />
<Setter Property="FontFamily"
Value="Roboto-Medium.ttf#Roboto-Medium" />
<Setter Property="TextTransform"
Value="Uppercase" />
<Setter Property="FontSize"
Value="Medium" />
</Style>
<Style x:Key="PrimaryButtonStyle"
TargetType="Button"
BasedOn="{StaticResource BaseButtonStyle}">
<Setter Property="BackgroundColor"
Value="Blue" />
<Setter Property="TextColor"
Value="Red" />
</Style>
<Style x:Key="PrimaryRoundedButton"
TargetType="Button"
BasedOn="{StaticResource PrimaryButtonStyle}">
<Setter Property="FontSize"
Value="Medium" />
<Setter Property="CornerRadius"
Value="50" />
<Setter Property="BorderColor"
Value="BlanchedAlmond" />
</Style>
<Style TargetType="Button" x:Key="AddZoneRoundedButton" BasedOn="{StaticResource PrimaryRoundedButton}">
<Setter Property="WidthRequest" Value="50" />
<Setter Property="HeightRequest" Value="50" />
</Style>
Main.xaml
<StackLayout>
<Button Style="{StaticResource AddZoneRoundedButton}" Text="Bouton" />
</StackLayout>
Steps to Reproduce
- Build and launch the app
- Notice how the button is not rounded enough. Place directly CornerRadius="50" on the MainPage.xaml to visualize difference.
Expected Behavior
The Button should be rounded with a value of 50.
Actual Behavior
The Button is rounded with a lower value (probably 6).
Basic Information
- Version with issue: 5.0.0.2515
- Last known good version: don't know
- Platform Target Frameworks:
- Android: 12.0
- NuGet Packages:
- Affected Devices: Google Pixel 4a
Environment
Microsoft Visual Studio Community 2022
Version 17.3.4
VisualStudio.17.Release/17.3.4+32901.215
Microsoft .NET Framework
Version 4.8.04084
Installed Version: Community
Visual C++ 2022 00482-90000-00000-AA059
Microsoft Visual C++ 2022
ASP.NET and Web Tools 17.3.376.3011
ASP.NET and Web Tools
Azure App Service Tools v3.0.0 17.3.376.3011
Azure App Service Tools v3.0.0
C# Tools 4.3.0-3.22423.10+b35bb0baca1071d50cc4f8cf5a1a89e7cc112461
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Code Cleanup On Save 1.0.12
Automatically run one of the Code Clean profiles when saving the document. This ensures your code is always formatted correctly and follows your coding style conventions.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Extensibility Message Bus 1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Mono Debugging for Visual Studio 17.3.20 (3f4cb00)
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 6.3.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Razor (ASP.NET Core) 17.0.0.2232702+e1d654e792aa2fe6646a6935bcca80ff0aff4387
Provides languages services for ASP.NET Core Razor.
ResX Resource Manager ResXManager
Manage localization of all ResX-based resources in one place. Shows all resources of a solution and lets you edit the strings and their localizations in a well-arranged data grid.
TypeScript Tools 17.0.10701.2001
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.3.0-3.22423.10+b35bb0baca1071d50cc4f8cf5a1a89e7cc112461
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 17.1.0-beta.22363.4+1b94f89d4d1f41f20f9be73c76f4b229d4e49078
Microsoft Visual F# Tools
Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.
VisualStudio.DeviceLog 1.0
Information about my package
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
Xamarin 17.3.0.296 (d17-3@a0ff24b)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 17.3.0.208 (remotes/origin/d17-3@e4f67afef)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 17.2.28 (9b3d244)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 13.0.0.0 (d17-3/030cd63)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: dffa5ab
Java.Interop: xamarin/java.interop/d17-3@7716ae53
SQLite: xamarin/sqlite/3.38.5@df4deab
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@14076a6
Xamarin.iOS and Xamarin.Mac SDK 15.12.0.2 (87f98a75e)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Build Logs
Screenshots
