Esta documentación está archivada y no tiene mantenimiento.

CheckBox (Clase)

Represents a control that a user can select and clear.

Espacio de nombres: System.Windows.Controls
Ensamblado: PresentationFramework (en presentationframework.dll)
Espacio de nombres XML:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[LocalizabilityAttribute(LocalizationCategory.CheckBox)] 
public class CheckBox : ToggleButton
/** @attribute LocalizabilityAttribute(LocalizationCategory.CheckBox) */ 
public class CheckBox extends ToggleButton
LocalizabilityAttribute(LocalizationCategory.CheckBox) 
public class CheckBox extends ToggleButton
<CheckBox>
  Content
</CheckBox>

CheckBox controls inherit from ToggleButton and can have three states: checked, unchecked, and indeterminate. For more information about the indeterminate state see Indeterminate.

You can display CheckBox controls in a group so that users can choose from a list of options. You can also offer users a combination of options.

ContentModel: A CheckBox is a ContentControl which means that a CheckBox can contain content such as text or images For more information about the CheckBox content model, see Content Control Content Model.

This example creates a CheckBox control.

The following example creates a CheckBox control by using markup to create the check box and code-behind to handle the Click event.

When a user selects the CheckBox, the text changes.

<CheckBox Margin="10, 10, 3, 3" Grid.Column="0" Grid.Row="2" Name="cb1" FontSize="12" 
Checked="HandleChange">Check Box</CheckBox>

private void HandleChange(object sender, RoutedEventArgs e)
{
    cb1.Content = "You clicked the check box";
}

For the complete sample, see CheckBox Sample.

Más código

How to: Include an Image in a CheckBox

This example shows how to include an Image in a CheckBox. The example illustrates that a check box can contain content other than text.

How to: Create a Control That Has an Access Key and Text Wrapping

This example shows how to create a control that has an access key and supports text wrapping. The example uses a Label control to illustrate these concepts.

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
             System.Windows.Controls.Control
               System.Windows.Controls.ContentControl
                 System.Windows.Controls.Primitives.ButtonBase
                   System.Windows.Controls.Primitives.ToggleButton
                    System.Windows.Controls.CheckBox

Los miembros estáticos públicos (Shared en Visual Basic) de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0
Mostrar: