Customized CheckBox : 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.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » Windows Presentation Foundation » CheckBoxScreenshots 
Customized CheckBox
Customized CheckBox
    
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Page.Resources>
        <ControlTemplate x:Key="switch" TargetType="{x:Type CheckBox}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Canvas Background="LightGray">
                    <Line Name="lineOff"
                              StrokeThickness="8" Stroke="Black"
                              X1="48" Y1="40" X2="20" Y2="16"
                              StrokeStartLineCap="Round"
                              StrokeEndLineCap="Round"  />
                    <Line Name="lineOn"
                              StrokeThickness="8" Stroke="Black"
                              X1="48" Y1="40" X2="76" Y2="16"
                              StrokeStartLineCap="Round"
                              StrokeEndLineCap="Round" 
                              Visibility="Hidden"  />
                </Canvas>
                <ContentPresenter Grid.Row="1" 
                                  Content="{TemplateBinding Content}"
                                  HorizontalAlignment="Center" />
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter TargetName="lineOff" Property="Visibility"
                            Value="Hidden" />
                    <Setter TargetName="lineOn" Property="Visibility"
                            Value="Visible" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Page.Resources>

    <CheckBox Template="{StaticResource switch}"
              Content="Customized CheckBox"
              HorizontalAlignment="Center"
              VerticalAlignment="Center" />
</Page>

   
    
    
    
  
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.CheckBox StyleCheckBox Style
5.CheckBox checked event listenerCheckBox checked event listener
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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.