- IsThreeState="True" : Checked(체크), Indterminate(-), Unchecked(해제)
- IsThreeState="False" : Checked(체크), Unchecked(해제
IsThreeState 기본 False입니다.
MainPage.xaml |
[그림 56-1] <Grid x:Name="LayoutRoot" Background="White"> <StackPanel> <StackPanel x:Name="my"> <TextBlock Text="당신의 관심사항은?"></TextBlock> <CheckBox Content="C#" IsChecked="False"></CheckBox> <CheckBox Content="ASP.NET" IsChecked=""></CheckBox> <CheckBox Content="SilverLight" IsChecked="True"></CheckBox> </StackPanel> <TextBlock><LineBreak></LineBreak></TextBlock> <CheckBox x:Name="chkShow" IsThreeState="False" Content="보이기"></CheckBox> </StackPanel> </Grid> |
MainPage.xaml.cs |
public partial class MainPage : UserControl { public
MainPage() { InitializeComponent(); this.chkShow.Click
+= new RoutedEventHandler(chkShow_Click); } void
chkShow_Click(object sender, RoutedEventArgs e) { //체크한 개체가 체크박스인지 확인 System.Windows.Controls.CheckBox chk = new
System.Windows.Controls.CheckBox(); if
(sender is System.Windows.Controls.CheckBox)//is 연선자 : ~개체이냐? true/false { //체크박스이면 해당 개체를 담고 그렇지 않으면 null chk = sender as System.Windows.Controls.CheckBox; } if
(chk == null) { return; }
bool
check = chk.IsChecked ?? false; //my 개체에 대해서 보임/숨김 my.Visibility = check ? Visibility.Visible : Visibility.Collapsed;
//3항연산자 } } } |
결과화면 |
[그림 56-2] |
'Silverlight' 카테고리의 다른 글
58.SilverLight3 - ScrollViewer (0) | 2009.12.02 |
---|---|
57.SilverLight3 - ToolTip (0) | 2009.12.02 |
55.SilverLight3 - RadioButton (0) | 2009.12.02 |
54.SilverLight3 - RepeatButton (0) | 2009.12.02 |
53.SilverLight3 - HyperlinkButton (0) | 2009.12.02 |
Comments