Handles CheckBox Indeterminate events when a CheckBox changes to a indeterminate state. : CheckBox « Windows Presentation Foundation « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Windows Presentation Foundation » CheckBoxScreenshots 
Handles CheckBox Indeterminate events when a CheckBox changes to a indeterminate state.
Handles CheckBox Indeterminate events when a CheckBox changes to a indeterminate state.
  
<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WPF" Height="250" Width="300">
    <StackPanel Name="panel">
        <CheckBox 
                  Content="Third CheckBox (Tri-State Enabled)" 
                  Indeterminate="CheckBox_Indeterminate"  IsChecked="True" 
                  IsThreeState="True" Margin="2" Name="checkbox3" 
                  />
        <Button Content="Get Selected" Margin="5" MaxWidth="100" 
                Click="Button_Click" />
        <TextBlock FontWeight="Bold" Text="Selected CheckBoxes:" />
        <ListBox Margin="5" MinHeight="2cm" Name="listbox" />
    </StackPanel>
</Window>
//File:Window.xaml.cs
using System.Linq;
using System.Windows;
using System.Windows.Controls;

namespace WpfApplication1
{
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            listbox.Items.Clear();
            foreach (CheckBox checkbox in panel.Children.OfType<CheckBox>().Wherecb => cb.IsChecked == true))
            {
                listbox.Items.Add(checkbox.Name);
            }
        }
        private void CheckBox_Indeterminate(object sender, RoutedEventArgs e)
        {
            if (!IsInitializedreturn;

            CheckBox checkbox = e.OriginalSource as CheckBox;

            if (checkbox != null)
            {
                MessageBox.Show(checkbox.Name + " is indeterminate.", Title);
            }
        }

    }
}

   
    
  
Related examples in the same category
1.Three-State CheckBoxThree-State CheckBox
2.A CheckBox with a skew transformationA CheckBox with a skew transformation
3.Add CheckBox to StackPanelAdd CheckBox to StackPanel
4.Customized CheckBoxCustomized CheckBox
5.CheckBox StyleCheckBox Style
6.CheckBox checked event listenerCheckBox checked event listener
7.Handle CheckBox Unchecked eventsHandle CheckBox Unchecked events
8.Handle CheckBox checked events
9.Use Linq to get checked CheckBoxUse Linq to get checked CheckBox
10.Check the CheckBox based on key pressed statesCheck the CheckBox based on key pressed states
11.CheckBox ListCheckBox List
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.