[WP7] CheckBox Window Phone7 2011. 12. 7. 16:16
CheckBox에는 3가지 상태가 존재한다.

Check, UnCheck, Indeterminate 상태가 있다.

처음에 두개는 익숙하게 보이겠지만 세번째의 모습은 일반적인 WinForm 개발자로서는 의아해 할 것이다.

직접 에뮬레이터를 돌려서 체크 단계를 확인을 해 보면 테두리가 생기는 단계가 있는데 그 단계가 나타난다.

그것이 여기에서 말하는 Indeterminate 상태이다.

이벤트를 같이 써야 함으로 CheckBox를 올린디 다중 선택을 하고 이벤트를 한거번에 걸어주고 난 다음

두번째의 CheckBox에만 따로 Indeterminate 이벤트를 먹여준다.

그렇게 하면 쉽게 이해가 갈 것이다 소스 코드추가는 다음과 같다.

위에 사진은 xaml 상에서 나타나는 것으로 아래는 실제 cs 코드이다.

private void checkBox2_Checked(object sender, RoutedEventArgs e)
        {
            CheckBox box = sender as CheckBox;
            if (box.Content.Equals("CheckBox 1"))
            {
                ApplicationTitle.Text = "checkbox 1";
            }
            else
            {
                ApplicationTitle.Text = "checkbox 2";
            }
        }

        private void checkBox2_Unchecked(object sender, RoutedEventArgs e)
        {
            CheckBox box = sender as CheckBox;
            if (box.Content.Equals("CheckBox 1"))
            {
                ApplicationTitle.Text = "checkbox 1";
            }
            else
            {
                ApplicationTitle.Text = "checkbox 2";
            }
        }

        private void checkBox2_Indeterminate(object sender, RoutedEventArgs e)
        {
            CheckBox box = sender as CheckBox;
            PageTitle.Text = "Indeterminate";
        }
이 내용을 실행하면 다음과 같이 나온다.