Logo
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
EPL Standings
 
 
Windows Phone

The App Bar and Controls - The Button Hierarchy

- 2015 Chevrolet Camaro Z28 - The Legend Returns
- Wagon Audi Allroad Vs. Subaru Outback
- 996 Carrera 4S is Driving Perfection
3/17/2011 4:40:36 PM
This class hierarchy is complete beginning with the ButtonBase class:
Control (abstract)
ContentControl
ButtonBase (abstract)
Button
HyperlinkButton
RepeatButton (sealed)
ToggleButton
CheckBox
RadioButton

It’s actually ButtonBase that defines the Click event and the ClickMode property.

The ButtonCornucopia project creates instances of all these buttons with nearly as few superfluous properties as possible:

Example 1. Silverlight Project: ButtonCornucopia File: MainPage.xaml
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<Button Content="Button" HorizontalAlignment="Center" />
<HyperlinkButton Content="HyperlinkButton" HorizontalAlignment="Center" />
<RepeatButton Content="RepeatButton" HorizontalAlignment="Center" />
<ToggleButton Content="ToggleButton" HorizontalAlignment="Center" />
<CheckBox Content="CheckBox" HorizontalAlignment="Center" />

<Border BorderBrush="White"
BorderThickness="1"
HorizontalAlignment="Center">
<StackPanel>
<RadioButton Content="RadioButton1" />
<RadioButton Content="RadioButton2" />
<RadioButton Content="RadioButton3" />
</StackPanel>
</Border>
</StackPanel>
</Grid>


The buttons may seem a bit large with too much space around them, but keep in mind that they need to provide adequate touch targets:



The HyperlinkButton is used in connection with Silverlight page navigation, and includes a NavigateUri property for that purpose. RepeatButton generates multiple Click events when the button is held down; its primary purpose is in the ScrollBar and Slider, and it’s rarely used elsewhere.

There is no functional difference between the ToggleButton and CheckBox. The difference is only visual, and that’s something that can be changed with a template. The Silverlight for Windows Phone Toolkit adds a ToggleButton derivative named ToggleSwitchButton that you’ve probably seen in the Settings section of a Windows Phone.

When checked, the RadioButton causes all its siblings to become unchecked. There is no special container for the RadioButton. Just put two or more in a panel (almost always a StackPanel) and they will turn off by themselves. RadioButton defines a GroupName property that allows you to differentiate multiple groups of mutually exclusive buttons that might be children of the same panel.

Normally the ToggleButton and CheckBox are physical manifestations of a Boolean. They turn on and off with successive clicks. But ToggleButton defines an IsThreeState property that optionally provides a third “indeterminate” state. Generally this is used only in connection with the CheckBox; the ToggleButton doesn’t even have a unique visual appearance for the indeterminate state.

Consequently, the IsChecked property defined by ToggleButton is not of type bool. It’s of type Nullable<bool> (also written as bool?) with three possible values: true, false, and null. If you need to set the IsChecked property to a null value in XAML you can use a special markup extension:

IsChecked="{x:Null}"

For conventional two-state toggling purposes, IsChecked usually needs to be cast to bool.

ToggleButton defines three events: Checked is fired when the button becomes checked, Unchecked when it becomes unchecked, and Indeterminate when it’s going into the third state. In most cases, a program using a ToggleButton or CheckBox needs to handle both the Checked and Unchecked events, but you can use the same handler for both events.

Top Search -----------------
- Windows Server 2008 R2 : Work with RAID Volumes - Understand RAID Levels & Implement RAID
- Windows Server 2008 R2 Administration : Managing Printers with the Print Management Console
- Configuring Email Settings in Windows Small Business Server 2011
- Windows Server 2008 R2 : Configuring Folder Security, Access, and Replication - Implement Permissions
- Monitoring Exchange Server 2010 : Monitoring Mail Flow
- Windows Server 2008 R2 :Task Scheduler
- Windows Server 2008 R2 : File Server Resource Manager
- Windows Server 2008 R2 : Installing DFS
- Exchange Server 2010 : Managing Anti-Spam and Antivirus Countermeasures
- Windows Server 2008 R2 : Configuring Folder Security, Access, and Replication - Share Folders
Other -----------------
- The App Bar and Controls - Theme Styles and Precedence
- The App Bar and Controls - The Concept of Content
- The App Bar and Controls - The Basic Button
- The App Bar and Controls - RangeBase and Slider
- The App Bar and Controls - Elements and Controls
- The App Bar and Controls - Jot and the ApplicationBar
- The App Bar and Controls - Jot and Touch
- The App Bar and Controls - Jot and Application Settings
- The App Bar and Controls - ApplicationBar Icons
- Issues in Application Architecture - Xna Tombstoning and Settings
 
 
Most view of day
- Programming the WshShell Object : Working with Shortcuts
- File Type Associations (part 2) - Change the Icon for All Files of a Type
- Using SharePoint 2010’s Catastrophic Restore Cmdlets
- BizTalk 2010 Recipes : Document Schemas - Creating Flat File Schemas via the Wizard
- SharePoint 2010 Search : Search Extensions - Visualization
- Maintaining Your Windows Vista System : Checking Free Disk Space
- System Center Configuration Manager 2007 : Distributing Packages - Creating Collections (part 5) - Exclusion Collections
- Empowering Users Through SharePoint 2010 Lists (part 3) - Creating a View in a List
- Windows Server 2008 R2 : Using Windows PowerShell (part 3) - Managing Processes
- Using Windows PowerShell in an Exchange Server 2010 Environment : Understanding the EMS Syntax
Top 10
- Advanced Windows 7 Programming : Working in the Background - DEVELOPING TRIGGER-START SERVICES (part 7)
- Advanced Windows 7 Programming : Working in the Background - DEVELOPING TRIGGER-START SERVICES (part 6)
- Advanced Windows 7 Programming : Working in the Background - DEVELOPING TRIGGER-START SERVICES (part 5)
- Advanced Windows 7 Programming : Working in the Background - DEVELOPING TRIGGER-START SERVICES (part 4)
- Advanced Windows 7 Programming : Working in the Background - DEVELOPING TRIGGER-START SERVICES (part 3)
- Advanced Windows 7 Programming : Working in the Background - DEVELOPING TRIGGER-START SERVICES (part 2)
- Advanced Windows 7 Programming : Working in the Background - DEVELOPING TRIGGER-START SERVICES (part 1)
- Advanced Windows 7 Programming : Working in the Background - ADVANTAGES OF WORKING IN THE BACKGROUND
- SharePoint 2013 : Health and Monitoring (part 4) - Timer Jobs, The Developer Dashboard
- SharePoint 2013 : Health and Monitoring (part 3) - Analytics, The Health Analyzer
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro