2012-07-02 4 views
1

라디오 버튼을 클릭 할 때 선택 또는 선택 해제 사이를 전환하도록 설정할 수 있습니까? 버튼 하나 하나에 특별한 이벤트를 작성하여 간단한 이벤트를 만들거나 간단한 속성을 설정해야합니까?WPF 및 Silverlight의 라디오 버튼

답변

4

라디오 버튼은 그룹화를 기반으로 확인 및 선택 해제를 처리합니다. 라디오 단추는 부모 컨트롤과 GroupName 속성으로 그룹화됩니다.

예를 들어, 다음은 두 가지 무선 옵션 그룹을 나타냅니다.

<StackPanel> 
    <RadioButton Content="Radio 1" /> 
    <RadioButton Content="Radio 2" /> 
    <RadioButton Content="Radio 3" /> 
    <RadioButton Content="Radio 4" /> 
</StackPanel> 
<StackPanel> 
    <RadioButton Content="Radio 5" /> 
    <RadioButton Content="Radio 6" /> 
    <RadioButton Content="Radio 7" /> 
    <RadioButton Content="Radio 8" /> 
</StackPanel> 

그러나 GroupName 속성을 사용하여, 우리는, 예를 들어, 세 그룹 수 : 위의 코드에서

<StackPanel> 
    <RadioButton GroupName="Group1" Content="Radio 1" /> 
    <RadioButton GroupName="Group2" Content="Radio 2" /> 
    <RadioButton GroupName="Group1" Content="Radio 3" /> 
    <RadioButton GroupName="Group2" Content="Radio 4" /> 
</StackPanel> 
<StackPanel> 
    <RadioButton Content="Radio 5" /> 
    <RadioButton Content="Radio 6" /> 
    <RadioButton Content="Radio 7" /> 
    <RadioButton Content="Radio 8" /> 
</StackPanel> 

을, 제 1 및 제 3 라디오는 2, 4 독립적으로 그룹화됩니다.