Radiobutton with ControlTemplate doesn't recognize Click Event Correctly
See original GitHub issueDescription
When Radiobutton visual structure is redefined with a ControlTemplate, the click event is not recognized correctly by radio button: 1-by clicking inside Radiobutton, the the Radiobutton is not selected(Checked) 2-clicking outside the Radiobutton, change Radiobutton state to Selected(Checked) state.
Steps to Reproduce
1-Create a New MAUI Project 2-Add new Page 3-Code:(code is taken from Microsoft page @ Redefine RadioButton appearance)
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
FlowDirection="LeftToRight"
x:Class="MauiApp29.Page1"
IconImageSource="edit.png"
Title="page1"
BackgroundColor="GreenYellow"
Padding="16">
<ContentPage.Resources>
<ControlTemplate x:Key="RadioButtonTemplate">
<Frame BorderColor="#F3F2F1"
BackgroundColor="#F3F2F1"
HasShadow="False"
HeightRequest="100"
WidthRequest="100"
HorizontalOptions="Start"
VerticalOptions="Start"
Padding="0">
<VisualStateManager.VisualStateGroups>
<VisualStateGroupList>
<VisualStateGroup x:Name="CheckedStates">
<VisualState x:Name="Checked">
<VisualState.Setters>
<Setter Property="BorderColor"
Value="#FF3300" />
<Setter TargetName="check"
Property="Opacity"
Value="1" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Unchecked">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="#F3F2F1" />
<Setter Property="BorderColor"
Value="#F3F2F1" />
<Setter TargetName="check"
Property="Opacity"
Value="0" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>
<Grid Margin="4"
WidthRequest="100">
<Grid WidthRequest="18"
HeightRequest="18"
HorizontalOptions="End"
VerticalOptions="Start">
<Ellipse Stroke="Blue"
Fill="White"
WidthRequest="16"
HeightRequest="16"
HorizontalOptions="Center"
VerticalOptions="Center" />
<Ellipse x:Name="check"
Fill="Blue"
WidthRequest="8"
HeightRequest="8"
HorizontalOptions="Center"
VerticalOptions="Center" />
</Grid>
<ContentPresenter />
</Grid>
</Frame>
</ControlTemplate>
<Style TargetType="RadioButton">
<Setter Property="ControlTemplate"
Value="{StaticResource RadioButtonTemplate}" />
</Style>
</ContentPage.Resources>
<ContentPage.Content>
<StackLayout>
<Label Text="What's your favorite mode of transport?" />
<RadioButton Content="Car" />
<RadioButton Content="Bike" />
<RadioButton Content="Train" />
<RadioButton Content="Walking" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
Version with bug
Release Candidate 2 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 8-Android 9
Did you find any workaround?
No response
Relevant log output
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:9
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Radio button control template binding "IsChecked" not ...
I have a control template like below, and I want to get IsChecked property when user selects a radio button. But when user...
Read more >RadioButton ControlTemplate not displayed as Checked in ...
I have a Xamarin.Forms ControlTemplate for a RadioButton defined as follows: <Style x:Key="RadioButtonStyle" TargetType="RadioButton"> <Setter…
Read more >RADIO BUTTONS in WPF? This is how it´s done - YouTube
The IsChecked property of a RadioButton can be set by clicking it, but it can ... For more information about creating a ControlTemplate,...
Read more >Grid doesn't always refresh a column with a custom ...
Hi, I have a problem with some custom templates for grid cells. I created a template that shows a RadioButton to better visualize...
Read more >Building a template-driven form
This tutorial shows you how to create a template-driven form. The control elements in the form are bound to data properties that have...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello, a workaround to solve is using a gesture like this:
And the code behind:
I have the same problem on android devices.