简体   繁体   中英

What is wrong with my XAML?

    <GroupBox x:Name="groupBox" Header="Operating System" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="74" Width="280">
        <RadioButton GroupName="Os" Content="Windows XP" IsChecked="True"/>
        <RadioButton GroupName="Os" Content="Windows Vista" />
        <RadioButton GroupName="Os" Content="Windows 7" />

    </GroupBox>

I get an error saying that I can't set the content more than once.

I am using C# with WPF

A group box is not a panel; it can only have a single child.

Try having a stack panel/similar inside it like this:

<GroupBox x:Name="groupBox" Header="Operating System" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="74" Width="280">
    <StackPanel>
        <RadioButton GroupName="Os" Content="Windows XP" IsChecked="True"/>
        <RadioButton GroupName="Os" Content="Windows Vista" />
        <RadioButton GroupName="Os" Content="Windows 7" />
    </StackPanel>
</GroupBox>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM