CheckBox checked event listener : CheckBox « Windows Presentation Foundation « C# / C Sharp






CheckBox checked event listener

CheckBox checked event listener
  


<Window x:Class="LayoutPanels.LocalizableText"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Layout" Height="365" Width="380" MinWidth="350" MinHeight="150">
  <Grid>
    <StackPanel>
      <Button Name="cmdPrev" Margin="10,10,10,3">Prev</Button>
      <Button Name="cmdNext" Margin="10,3,10,3">Next</Button>      
      <CheckBox Name="chkLongText" Margin="10,10,10,10" Checked="chkLongText_Checked" Unchecked="chkLongText_Unchecked">Show Long Text</CheckBox>
    </StackPanel>    
    <TextBox  Margin="0,10,10,10" TextWrapping="WrapWithOverflow">
     This behavior makes localization much easier.</TextBox>
    <Button Grid.Row="1" Grid.Column="0" Name="cmdClose" Margin="10,3,10,10">Close</Button>
  </Grid>
</Window>

//File:Window.xaml.cs

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace LayoutPanels
{

    public partial class LocalizableText : Window
    {

        public LocalizableText()
        {
            InitializeComponent();
        }

        private void chkLongText_Checked(object sender, RoutedEventArgs e)
        {            
            cmdPrev.Content = " <- Go to the Previous Window ";
            cmdNext.Content = " Go to the Next Window -> ";
        }

        private void chkLongText_Unchecked(object sender, RoutedEventArgs e)
        {
            cmdPrev.Content = "Prev";
            cmdNext.Content = "Next";
        }
    }
}

   
    
  








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.Handles CheckBox Indeterminate events when a CheckBox changes to a indeterminate state.Handles CheckBox Indeterminate events when a CheckBox changes to a indeterminate state.
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