XAML mukti单选按钮组和标签

XAML mukti单选按钮组和标签,xaml,grid,ischecked,Xaml,Grid,Ischecked,嗨,我是xaml新手,我试着读过一些样本,但我迷路了 现在我有两个问题 我希望标签文本首先在按钮之前,文本与按钮文本对齐,或者有标签文本、换行符,然后是按钮 我无法使这两个单选按钮组的默认值处于选中状态。只有最后一个组设置了ischecked=true,第一个组被忽略 所以请帮助我,我有点不对劲,我不知道那是什么:( #96d1ff <ContentPage.BindingContext> <vm:AboutViewModel /> </Conten

嗨,我是xaml新手,我试着读过一些样本,但我迷路了

现在我有两个问题

  • 我希望标签文本首先在按钮之前,文本与按钮文本对齐,或者有标签文本、换行符,然后是按钮

  • 我无法使这两个单选按钮组的默认值处于选中状态。只有最后一个组设置了ischecked=true,第一个组被忽略

  • 所以请帮助我,我有点不对劲,我不知道那是什么:(

    
    #96d1ff
    
    <ContentPage.BindingContext>
        <vm:AboutViewModel />
    </ContentPage.BindingContext>
    
    <ContentPage.Resources>
        <ResourceDictionary>
            <Color x:Key="Accent">#96d1ff</Color>
        </ResourceDictionary>
    </ContentPage.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackLayout BackgroundColor="{StaticResource Accent}" VerticalOptions="FillAndExpand" HorizontalOptions="Fill">
            <StackLayout Orientation="Horizontal" HorizontalOptions="Center" VerticalOptions="Center">
                <ContentView Padding="0,40,0,40" VerticalOptions="FillAndExpand">
                    <Image Source="xamarin_logo.png" VerticalOptions="Center" HeightRequest="64" />
                </ContentView>
            </StackLayout>
    
            <StackLayout>
                <StackLayout>
                    <Frame BackgroundColor="White" BorderColor="Black">
                        <Grid ColumnDefinitions="*,*,*" ColumnSpacing="10" x:Name="Grid1">
                            <!--<Button Text="t1"></Button>-->
    
                            <Label Text="Radio button group 1" HorizontalTextAlignment="Center"></Label>
    
                            <RadioButton IsChecked="True" Content="None"  BackgroundColor="White" GroupName="Group1" />
                            <RadioButton Grid.Column="1" Content="Light"  BackgroundColor="#F0FF00" GroupName="Group1" />
                            <RadioButton Grid.Column="2" Content="Moderate"  BackgroundColor="#ffba08" GroupName="Group1" />
                            <RadioButton Grid.Column="3" Content="Severe"  BackgroundColor="#dc2f02" GroupName="Group1" />
                        </Grid>
                    </Frame>
                </StackLayout>
    
                <StackLayout>
                    <Frame BackgroundColor="White" BorderColor="Black">
                        <Grid ColumnDefinitions="*,*,*" ColumnSpacing="10" x:Name="Grid2" >
                            <Label Text="Radio button group 2" HorizontalTextAlignment="Center"></Label>
                            <RadioButton IsChecked="True" Content="None"  BackgroundColor="White" GroupName="Group2" />
                            <RadioButton Grid.Column="1" Content="Light"  BackgroundColor="#F0FF00" GroupName="Group2" />
                            <RadioButton Grid.Column="2" Content="Moderate"  BackgroundColor="#ffba08" GroupName="Group2" />
                            <RadioButton Grid.Column="3" Content="Severe"  BackgroundColor="#dc2f02" GroupName="Group2" />
                        </Grid>
                    </Frame>
                </StackLayout>
            </StackLayout>
        </StackLayout>
    </Grid>