docs-maui icon indicating copy to clipboard operation
docs-maui copied to clipboard

CheckBox Documentation Missing Required Element For Visual Style

Open heribertolugo opened this issue 1 year ago • 0 comments

Issue description

Documentation for CheckBox provides the following example for manipulating the color of the CheckBox:

<CheckBox ...>
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="CommonStates">
            <VisualState x:Name="Normal">
                <VisualState.Setters>
                    <Setter Property="Color"
                            Value="Red" />
                </VisualState.Setters>
            </VisualState>

            <VisualState x:Name="IsChecked">
                <VisualState.Setters>
                    <Setter Property="Color"
                            Value="Green" />
                </VisualState.Setters>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
</CheckBox>

If you copy and paste that code you will receive the following error when trying to run the project:

image

The fix is to include the <VisualStateGroupList> as the child for the <VisualStateManager.VisualStateGroups> as stated in this StackOVerFlow post, like so:

<CheckBox ...>
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroupList>
            <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal">
                    <VisualState.Setters>
                        <Setter Property="Color"
                            Value="Red" />
                    </VisualState.Setters>
                </VisualState>

                <VisualState x:Name="IsChecked">
                    <VisualState.Setters>
                        <Setter Property="Color"
                            Value="Green" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateGroupList>
    </VisualStateManager.VisualStateGroups>
</CheckBox>

This should be reflected in the documentation.

heribertolugo avatar Mar 28 '24 17:03 heribertolugo