Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Phone

The App Bar and Controls - The Basic Button

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
3/17/2011 4:35:57 PM
The standard Silverlight Button is much more flexible than the ApplicationBar buttons, as well as being easier to use. You can put a Button in the content Grid as simply as this:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="Click me!" />
</Grid>

By default, the Button fills the Grid:



It has a simple white border and displays the text string assigned to its Content property. If you put the Button in a horizontal StackPanel, it will be only as wide as it needs to be to fit the content; the opposite effect happens when you switch the StackPanel orientation to Vertical. Or you can set the HorizontalAlignment and VerticalAlignment properties to anything other than Stretch:



Obviously the basic Button has been redesigned a bit for the phone. It has a little more space around its border to provide a larger touch target.

The border in the Button is an actual Border and the content of the Button (in this example) is an actual TextBlock. Earlier I mentioned that the Control class defines a bunch of properties normally associated with the Border and the TextBlock. You can set some of those properties like so:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="Click me!"
FontSize="48"
FontStyle="Italic"
Foreground="Red"
Background="Blue"
BorderThickness="10"
BorderBrush="Yellow"
Padding="20"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>

As you might hope (or perhaps fear), these property settings are reflected in the button’s appearance:



The Control class also defines HorizontalContentAlignment and VerticalContentAlignment and Padding properties that you can set like so:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="Click me!"
Padding="50 100"
HorizontalContentAlignment="Right"
VerticalContentAlignment="Bottom" />
</Grid>

Now the content is positioned at the lower-right corner but 50 pixels from the right and 100 pixels from the bottom:



The Control class defines an IsEnabled property; when set to false, the Button is grayed and does not respond to touch.

Almost always you’ll want to set a handler for the Click property of the Button to know when it’s been pressed. The Click event is generated only when the user presses the Button and then releases the finger without moving away. Setting the ClickMode property to Press causes the Button to fire the Click event when the finger first meets the screen.

Other -----------------
- 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
- Issues in Application Architecture - Isolated Storage
- Issues in Application Architecture - Page State
- Issues in Application Architecture - Task Switching on the Phone
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server