Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Dinesh's Blog
Browse by Tags · View All
brh 20
#SILVERLIGHT 19
#DOTNET 18
silverlight 18
#ASP.NET 15
Silverlight 4.0 9
bing 7
bing maps 6
wcf services 5
map 5

Archive · View All
August 2010 10
September 2010 3
July 2010 3
June 2010 3
October 2010 1

Layout Management Panels in Silverlight

Aug 23 2010 7:00AM by Dinesh Sodani   

In the previous article I described how to create a simple Silverlight application in Microsoft Visual Studio 2010. In this article I will describe what are the different Layout Management Panels in Silverlight and how and when they are used. When you create a Silverlight project using Visual Studio, it creates a default XAML file called "MainPage.xaml". This is just a dummy start page created by Visual Studio and it does not contain any visible UI elements. The default content of the MainPage.xaml file looks like this:

<UserControl x:Class="HelloWorld.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"   
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot">
       
  </Grid>
</UserControl>

The above code shows a user control and a Grid control. The UserControl is a high level control that holds all other UI elements in a XAML file. The Grid control is used as a layout panel and it can hold other UI elements. All UI elements in a .XAML control must be placed within a layout panel. There are 3 different types of layout panels available in Silverlight.

  1. Grid Panel
  2. Stack Panel
  3. Canvas Panel

Each of these methodologies fit in to different situations as per layout needs. All these layout controls inherit from Panel class.

Grid Layout

Grid layout helps you position your controls using rows and columns. It’s very similar to table defined in HTML.

Grid Layout

Above we created a simple table with two columns and two rows. Using Grid.ColumnDefinitions we defined two columns and using Grid.RowDefinitions we defined two rows. Then We created 4 text blocks which are then specified in each section using Grid.Column and Grid.Row. For instance to place in the first column we need specify the Grid.Column as “0”and Grid.Row as “0”.

Stack Layout

Stack allows you to arrange/group UI elements vertically or horizontally. Controls do not overlap. For instance below are 4 elements which are arranged in a stack panel element. You can see how the stack aligns / stacks the elements one above other. You can also stack the UI elements horizontally or vertically depending on your layout nature.

Stack Panel

By default Orientation is Vertical. You can arrange controls horizontally by using Orientation = Horizontal. You can use Margin Property to change the location on control inside the stack panel. See below

Stack Panel Horizontal

Canvas Layout

Canvas is the simplest methodology for layout management. It supports absolute positioning using ‘X’ and ‘Y’ coordinates. Canvas.Left helps to specify the X co-ordinate while Canvas.Top helps to provide the ‘Y’ coordinates.

You can think Canvas as a HTML div Tag, where you can put your content in specific location by providing absolute left and top position.

Canvas

If you are familiar with Photoshop, Photoshop creates layers to position them on top of each other. Canvas.ZIndex property of controls does the same. Greater the ZIndex control will appear on the top.

Tags: silverlight, brh, #DOTNET, #SILVERLIGHT, #ASP.NET, Silverlight 4.0, Grid Layout, Canvas Layout, Grid.ColumnDefinitions, Stack Layout, Stack Orientation, Canvas.ZIndex, Grid.RowDefinitions,


Dinesh Sodani
30 · 6% · 1807
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]