Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RadioButton ControlTemplate ignored on Windows #6630

Closed
LordBenjamin opened this issue Apr 28, 2022 · 2 comments · Fixed by #6785
Closed

RadioButton ControlTemplate ignored on Windows #6630

LordBenjamin opened this issue Apr 28, 2022 · 2 comments · Fixed by #6785
Assignees
Labels
fixed-in-6.0.312 Look for this fix in 6.0.312! legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor p/0 Work that we can't release without platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@LordBenjamin
Copy link

LordBenjamin commented Apr 28, 2022

Description

When running on Windows, the RadioButton does not respect the specified ControlTemplate.

This is despite the documentation stating that:

By default, RadioButton objects use handlers to utilize native controls on supported platforms. However, RadioButton visual structure can be redefined with a ControlTemplate, so that RadioButton objects have an identical appearance on all platforms. This is possible because the RadioButton class inherits from the TemplatedView class.

Windows:
image

Android:
image

Steps to Reproduce

  1. Create new MAUI app
  2. Add ControlTemplate and Style to App.xaml as below (this is a modified version of Microsoft's own example) :
    <ControlTemplate
        x:Key="RadioButtonControlTemplate">
        <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="Green" />
                                <Setter TargetName="check"
                                    Property="Opacity"
                                    Value="1" />
                            </VisualState.Setters>
                        </VisualState>
                        <VisualState x:Name="Unchecked">
                            <VisualState.Setters>
                                <Setter Property="BackgroundColor"
                                    Value="Green" />
                                <Setter Property="BorderColor"
                                    Value="Yellow" />
                                <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
        x:Key="RadioButtonStyle"
        TargetType="RadioButton">
        <Setter Property="BorderColor" Value="Red" />
        <Setter Property="WidthRequest" Value="60" />
        <Setter Property="HeightRequest" Value="60" />
        <Setter Property="MaximumWidthRequest" Value="60" />
        <Setter Property="MaximumHeightRequest" Value="60" />
        <Setter Property="MinimumWidthRequest" Value="60" />
        <Setter Property="MinimumHeightRequest" Value="60" />
        <Setter Property="Content" Value="{x:Null}" />
        <Setter Property="ControlTemplate" Value="{StaticResource RadioButtonControlTemplate}" />
    </Style>
  3. Add RadioButtons to the MainPage.xaml (note that the last RadioButton explicitly defines ControlTemplate, also to no effect:
    <RadioButton
        Grid.Row="0"
        Style="{StaticResource RadioButtonStyle}" />
    <RadioButton
        Grid.Row="1"
        Style="{StaticResource RadioButtonStyle}" />
    <RadioButton
        Grid.Row="2"
        Style="{StaticResource RadioButtonStyle}"
        ControlTemplate="{StaticResource RadioButtonControlTemplate}"  />

Version with bug

Release Candidate 2 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows 10 (21H1 | 19043.1645)

Did you find any workaround?

No.

Relevant log output

No response

@LordBenjamin LordBenjamin added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Apr 28, 2022
@LordBenjamin
Copy link
Author

@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Apr 28, 2022
@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Apr 29, 2022
@XamlTest
Copy link

Verified this issue with Visual Studio Enterprise 17.3.0 Preview 1.0 [32427.455.main]. Repro on Windows with above project.

@Redth Redth added this to the 6.0.300 milestone May 3, 2022
@Redth Redth added the p/0 Work that we can't release without label May 3, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jun 2, 2022
@samhouts samhouts added the fixed-in-6.0.312 Look for this fix in 6.0.312! label Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-6.0.312 Look for this fix in 6.0.312! legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor p/0 Work that we can't release without platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants