Logo
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
PREGNANCY
 
 
Windows Phone

Windows Phone 8 : Designing for the Phone - Blend Basics (part 1) - Layout

4/24/2013 6:17:22 PM

Much like any activity, learning Blend is a matter of performing tasks and repeating them. The more you do, the more the muscle memory of Blend will take over and allow you to create great applications.

1. Layout

The most basic layout task you will accomplish is simply drawing elements on the screen. With a new application project, if you draw a control (for example, Button) on the page, you will notice that the size of the control will be shown as you drag, as shown in Figure 1.

Figure 1. Dragging a new control

Image

When you let go of the mouse button, you will notice that the control includes eight handles for resizing the control. Just outside these handles are lines that radiate outward from the control with small numbers near them. The usual way that XAML (and Blend) handles layout is by converting your object size to a margin from the side of the container (in this case a grid). So in Figure 2, you can see a “25” near the top and both sides of the new button. This indicates that the top, right, and left margins are 25 in size. Near each number is a small closed chain icon that indicates that the object is tied to these edges of the container. The bottom of the button has a dotted line that leads to an open chain icon that indicates that the button is not tied to the bottom. Because it is not tied to the bottom of the container, the margin doesn’t appear either (because the margin wouldn’t matter in this case). Using this metaphor of chaining to an edge can let you infer the alignment (top vertical aligned and stretch aligned horizontally). You can see the actual alignment and margin in the Properties panel that match this information. You can change these margins and alignments either directly on the artboard or by using the Properties panel.

Figure 2. Margin and alignment layout

Image

Most of the dynamic containers (Grid, StackPanel, and WrapPanel) all handle layout in this simple manner. The container in this example is the Grid. The Grid is different (and probably the most common of the containers) in that it enables you to create rows and columns. Blend makes it easy to create these rows and columns.

In a new simple Windows Phone application, Blend creates three Grids (LayoutRoot, TitlePanel, and ContentPanel). If you expand the LayoutRoot and select the ContentGrid in the Objects and Timeline panel, you will see that Blend shows a top- and left-side gutter for the grid, as shown in Figure 3.

Figure 3. Column and row gutters

Image

These gutters are important as you can click them to create columns and rows. Clicking the grid will create a split in the container that indicates where two rows or columns are separated. For example, if you click the left gutter about halfway down you’ll see two rows created, as shown in Figure 4.

Figure 4. Splitting the grid into rows

Image

After the grid is split into two rows, you should notice the text indicators next to each row that indicate the way the row (or column) is sized. There are three types of sizing: auto, fixed, and star sizing. The text indicator in Figure 4 shows that the two rows are star sized (as they are post-pended with an asterisk). When you hover on the text indicator, it shows a drop-down (see Figure 5).

Figure 5. Row/Column modification drop-down

Image

You can use this drop-down to change the type of row or column to an auto-sized or fixed-sized column/row. You can also choose to select the row or add or remove columns/rows.

When working with multiple columns and rows, Blend draws only what you like, but because you are creating applications that have to deal with different screen sizes, this it potentially hazardous. The problem is that fixed sizes are notoriously finicky with fixed sizes, and the recommendation is to make your applications just adjust size with the screen size. The best way to do this is to use what Blend calls “Quadrant Sizing”. To ensure this, go to the Blend Options (for example, use the Tool menu and pick Options). In Figure 6, this option is turned on.

Figure 6. Enabling Quadrant Sizing

Image

With Quadrant Sizing enabled, you can stretch objects across the row and column boundaries. Blend will do its best to help you determine which columns and rows you want to be a part of, but it is just guessing your intent. For example, you can see in Figure 7 that when an item just enters a second row, it handles this with a negative margin value.

Figure 7. Sizing across rows

Image

But if you stretch that more, Blend assumes you want to span the two rows, as shown in Figure 8.

Figure 8. Sizing across rows with RowSpan

Image

You will often need to manipulate the Row, Column, RowSpan, ColumnSpan, Alignment, and Margin entries manually in the Properties panel to get the exact behavior you want. In many cases you might not want to use margins at all, but rather make your object a fixed size. You can do this by ensuring that your object is not set to Stretch alignment (vertically and horizontally). Then the Margin box will indicate where to draw your element, but not how to size your element.

Other -----------------
- Windows Phone 8 : Designing for the Phone - Microsoft Expression Blend
- Windows Phone 7 Programming Model : Asynchronous Programming - Background Threads
- Windows Phone 8 : Designing for the Phone - Deciding on an Application Paradigm
- Windows Phone 8 : Designing for the Phone - The Third Screen
- Windows Phone 7 Programming Model : Web Browser Control
- Windows Phone 7 Programming Model : Tasks
- Windows Phone 7 Programming Model : Application Data Persistence
- Windows Phone 7 Programming Model : Device Information
- iphone Programming : Mixing OpenGL ES and UIKit, Rendering Confetti, Fireworks, and More: Point Sprites
- iphone Programming : Animation with Sprite Sheets, Image Composition and a Taste of Multitexturing
- XNA Game Studio 3.0 : Creating Game Components - Adding Game Sounds
- Iphone Application : Using Gesture Recognizers (part 4)
- Iphone Application : Using Gesture Recognizers (part 3)
- Iphone Application : Using Gesture Recognizers (part 2)
- Iphone Application : Using Gesture Recognizers (part 1)
- Handling Input on Windows Phone 7 : Microphone Input
- Handling Input on Windows Phone 7 : Accelerometer
- XNA Game Studio 4.0 : XNA Game Studio Storage (part 2) - Getting a Device
- XNA Game Studio 4.0 : XNA Game Studio Storage (part 1) - Recreating the Project on Xbox, Devices and Containers
- XNA Game Studio 4.0 : Storage - Isolated Storage
 
 
Most view of day
- Planning Deployment : Installing BDD 2007
- Troubleshooting Stop Messages : Common Stop Messages (part 1)
- Windows Server 2008 R2 : Creating and Administering Hyper-V Virtual Machines (part 1) - Virtual machine disk types
- Microsoft Visio 2010 : Working with Data - Creating Reports (part 1) - Introducing the Report Definition Wizard
- Windows Phone 8 : Working with File Explorer (part 2) - Removing Media from Your Phone
- Adobe Flash Catalyst CS5 : Convert Artwork to a Data List
- Editing Digital Video with Windows Live Movie Maker (part 6) - Editing Your Video - Trimming Video and Audio
- Sharing Your Computer with Others : Display User Accounts
- Microsoft Exchange Server 2007 : Consolidating a Windows 2000 Domain to a Windows Server 2003 Domain Using ADMT (part 4) - Migrating User Accounts
- Managing Client Protection : User Account Control (part 1) - UAC for Standard Users, UAC for Administrators
Top 10
- Integrating SharePoint 2013 with the Office Applications (part 10) - Microsoft Outlook - Lists and Libraries
- Integrating SharePoint 2013 with the Office Applications (part 9) - Microsoft InfoPath - Customizing the Document Information Panel and List Forms
- Integrating SharePoint 2013 with the Office Applications (part 8) - Microsoft InfoPath -Deploying a Form Via Central Administration, Rendering a Form Using the InfoPath Form Web Part
- Integrating SharePoint 2013 with the Office Applications (part 7) - Microsoft Access - Access Services
- Integrating SharePoint 2013 with the Office Applications (part 6) - Microsoft Access
- Integrating SharePoint 2013 with the Office Applications (part 5) - Microsoft OneNote
- Integrating SharePoint 2013 with the Office Applications (part 3) - Microsoft Excel
- Integrating SharePoint 2013 with the Office Applications (part 3) - Microsoft Excel
- Integrating SharePoint 2013 with the Office Applications (part 2) - Microsoft Word - Compare Document Versions, Quick Parts
- Integrating SharePoint 2013 with the Office Applications (part 1) - Microsoft Word - Writing Blog Posts
 
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro