Blog Content

    티스토리 뷰

    56.SilverLight3 - CheckBox

    반응형
    CheckBox 속성
    - 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;               

            }

           

            //null (true) true, (false)...

            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