IT tutorials

Windows Phone 8 : Receiving Input with Buttons

11/25/2014 3:18:18 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Receiving Input with Buttons

In most Windows Phone XAML apps, buttons are the most commonly used element for receiving user input. Ordinarily, a button initiates an action when a user taps it. Unlike Silverlight for the browser, the minimum size of the Button has been increased, making it more amenable to touch. The shape is usually rectangular, and the standard layout allows for either text or an image to be displayed as content. Buttons support three visibility states: rest (the default state), pressed, and disabled. Unlike Silverlight for the browser, however, there is no visible focus state.

The inherited FrameworkElement.HorizonalAlignment and VerticalAlignment properties both default to Stretch. The Button’s Horizontal and Vertical size, therefore, depends on its parent’s size; the bigger the parent ContentControl the bigger the button. By placing a Button in a Grid, the Button is free to expand to inhabit the entirety of the space provided by the Grid (see Figure 1).


FIGURE 1 By default a Button will expand to inhabit its parent.

If the parent ContentControl happens to be a StackPanel, the button will not expand farther than the space allowed. By default, the StackPanel arranges its child controls vertically. The StackPanel inhabits the entire width of its parent control, but only uses as much vertical space as it needs (see Figure 2).


FIGURE 2 Button conforms to the vertical size constraints afforded by the StackPanel.

To constrain the button size to the size of its content, set its HorizontalAlignment and VerticalAlignment properties to something other than Stretch. An effective way to do this is by using a style, as shown in the following example:

<Style x:Key="ButtonStyle" TargetType="ButtonBase">
    <Setter Property="HorizontalAlignment" Value="Left" />
    <Setter Property="VerticalAlignment" Value="Top" />

The style can then be applied like so:

<Button Content="Press me!" Style="{StaticResource ButtonStyle}" />

- Windows Phone 8 : Content Controls - Defining the Default Content Property
- Windows Phone 8 : Control Type Taxonomy - Identifying Controls Not Supported or Absent in Windows Phone
- Windows Phone 8 : Working with People - Facebook Integration (part 5) - Viewing a Friend’s Facebook Albums
- Windows Phone 8 : Working with People - Facebook Integration (part 4) - Writing on a Friend’s Facebook Wall , Viewing Facebook Wall Photos
- Windows Phone 8 : Working with People - Facebook Integration (part 3) - Commenting on a Wall Post
- Windows Phone 8 : Working with People - Facebook Integration (part 2) - Viewing a Wall Post, Viewing Comments to Wall Posts
- Windows Phone 8 : Working with People - Facebook Integration (part 1) - Connecting to Facebook
- Windows Phone 8 : Working with People - Rooms (part 8) - Adding an Appointment to the Shared Calendar , Creating a New Shared Note, Viewing Shared Notes
- Windows Phone 8 : Working with People - Rooms (part 7) - Viewing Shared Photos and Videos, Viewing the Shared Calendar
- Windows Phone 8 : Working with People - Rooms (part 6) - Sharing Photos and Videos
Top 10
Technology FAQ
- Microsoft ebs security server configuration
- IIs7 on Windows server 2003
- How to Configure Failover Clusters With Win 2008 Server R2?
- Windows 2008 Network Load Balancing
- Windows Server 2008 - Group Policy Management - Remove Computer Management
- Remove shortcuts possibility in a web page or to put in favorite
- HTA Dynamic Drop Down List
- IIS host header and DNS
- VMware or MS Virtual Server?
- Adobe Acrobat 9 inserting tab pages
programming4us programming4us