xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

Xamarin custom radio button is not selectable on iOS #15655

Open vsfeedback opened 1 year ago

vsfeedback commented 1 year ago

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice] If I create a custom radio control in Xamarin Forms it runs fine under Android but I can not select it under iOS. I tried the samples as on https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/radiobutton#radiobutton-visual-states

The states show as expected but I can not alter the selection, the behave if they are disabled.

For example I use the below control template

But any control template I apply has the same effect.

I have the most recent vs2022 configuration:

Microsoft Visual Studio Professional 2022 Version 17.4.3 VisualStudio.17.Release/17.4.3+33205.214 Microsoft .NET Framework Version 4.8.09032

Installed Version: Professional

Visual C++ 2022 00476-80000-00000-AA132 Microsoft Visual C++ 2022

ASP.NET and Web Tools 17.4.326.54890 ASP.NET and Web Tools

Azure App Service Tools v3.0.0 17.4.326.54890 Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 17.4.326.54890 Azure Functions and Web Jobs Tools

C# Tools 4.4.0-6.22580.4+d7a61210a88b584ca0827585ec6e871c6b1c5a14 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Clear MEF Component Cache 1.4 Clears the Visual Studio MEF component cache to fix issues with cache corruption.

CodeMaid 12.0 CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Cookiecutter 17.0.22263.6 Provides tools for finding, instantiating and customizing templates in cookiecutter format.

Dotfuscator Community Edition 6.5.0+76d4669002 PreEmptive Protection - Dotfuscator CE

Extensibility Message Bus 1.4.1 (main@2ee106a) 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.4.19 (8c0a575) Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 6.4.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Python - Profiling support 17.0.22263.6 Profiling support for Python projects.

Python with Pylance 17.0.22263.6 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Razor (ASP.NET Core) 17.0.0.2246202+61cc048d36a3fc9246d2f04625988b19a18ab8f0 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.

SQL Server Data Tools 17.0.62207.28050 Microsoft SQL Server Data Tools

TypeScript Tools 17.0.10921.2001 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.4.0-6.22580.4+d7a61210a88b584ca0827585ec6e871c6b1c5a14 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.4.0-beta.22512.4+525d5109e389341bb90b144c24e2ad1ceec91e7b 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.4.0.312 (d17-4@be7e8d1) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 17.4.0.138 (remotes/origin/d17-4@d36bba3cc9) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 17.4.2 (c457c97) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 13.1.0.1 (d17-4/13ba222) Xamarin.Android Reference Assemblies and MSBuild support. Mono: a96bde9 Java.Interop: xamarin/java.interop/d17-4@fcc33ce2 SQLite: xamarin/sqlite/3.39.3@23e1ae7 Xamarin.Android Tools: xamarin/xamarin-android-tools/main@0be567a

Xamarin.iOS and Xamarin.Mac SDK 16.1.1.27 (933c6c2c9) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

So I'm stuck and have no clue what is going on??

An example screensnap Screenshot 2023-01-07 130209.png


Original Comments

Feedback Bot on 1/8/2023, 06:15 PM:

(private comment, text removed)


Original Solutions

Martien Poels solved on 1/13/2023, 05:19 AM, 0 votes:

I now have found a workaround for it, although the behaviour is very strange.

If I add a key to it so that I have to apply the style specifically, the selection mechanism is working again

this works in App.xml

<Style x:Key="customRadioButton" TargetType="RadioButton">
    <Setter Property="ControlTemplate" Value="{StaticResource RadioButtonTemplate}" />
</Style>

If I set it as a control template for all radiobutton’s the selection is not possible (only under iOS. Android operates correctly for both codes) I can reproduce this over and over.
I have another project and I tested this there and same effect. As soon as I make it default, selection is not possible under iOS anymore.

<Style TargetType="RadioButton">
    <Setter Property="ControlTemplate" Value="{StaticResource RadioButtonTemplate}" />
</Style>

So this should not be hard to reproduce on your side too! At least I have a workaround now so I can release the app finally

Regards martien,