2015-05-21 119 views
1
<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> 

我收到一個錯誤消息,說我不能多次設置內容。我的XAML有什麼問題?

我使用C#和WPF

回答

6

組框不是面板;它只能有一個孩子。

嘗試具有堆疊面板/裏面類似這樣的:

<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>