#359 – ToggleButton Basics

The ToggleButton control is similar to the CheckBox control, in that allows the user to toggle something on/off in an application.  Instead of looking like a checkmark next to a label, however, the ToggleButton looks like a normal button.  The button appears to stay pressed in after you click it.  When you click the ToggleButton a second time, it appears to pop back out.

You specify the text that appears on the face of the ToggleButton using the Content property.

        <StackPanel Orientation="Horizontal">
            <ToggleButton Content="Bold" FontWeight="Bold" Padding="5"/>
            <ToggleButton Content="Italic" FontStyle="Italic" Padding="5"/>
            <ToggleButton Padding="5" >
                <TextBlock>
                    <Underline>Underline</Underline>
                </TextBlock>
            </ToggleButton>
        </StackPanel>

Like the CheckBox control, the IsChecked property indicates whether the ToggleButton is currently checked.

Also like the CheckBox control, the Checked and Unchecked events fire when the ToggleButton is checked or unchecked.

Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #359 – ToggleButton Basics

  1. Pingback: Dew Drop – August 8, 2011 | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: