Layout in XAML
page 2 of 8
by Keyvan Nayyeri
Average Rating: 
Views (Total / Last 10 Days): 46848/ 88

Width and Height

The simplest features that allow you to lay your elements out are something similar to what you saw in XHTML and CSS before: Width and Height.

Any element that is derived from a FrameworkElement class has these two attributes that allow you to set its size.  Based on the container of an element, these elements can work as how they seem to work or can be cut to keep consistency (you will see some examples later).  Listing 1 shows a simple TextBox in a Window with Width and Height attributes set for it and you can see the output in Figure 1.  Attend to the Window element itself, it has its own Width and Height attributes.

Listing 1

<Window x:Class="LayoutinXAML.Window1"
    Title="Layout in XAML" Height="150" Width="300"
  <TextBox Width="200" Height="30">
    ASP Alliance

Figure 1

View Entire Article

User Comments

Title: Good One....   
Name: Satish
Date: 2011-01-31 5:57:16 AM
Thanks for the article
Title: Margins and Canvas.Top/Left   
Name: Amir
Date: 2010-04-17 8:50:03 PM

What is the difference between margins and Canvas.Left/Top/Right/Bottom? They both seem to define left, top, right and bottom distances. If that's the case then I don't understand what they mean when they say Canvas uses absolute positioning and grid uses relative positioning.

Title: Complement   
Name: Mehta Chandni K.
Date: 2009-02-09 4:08:59 AM
A very good article. I got to learn many basic and important things on XAML. Thank you very much. Keep uploading such articles for students like us..
Title: XAML Layout   
Name: Anjan
Date: 2007-05-15 6:53:25 AM
It is fine with windows.I want to Layout the Page with WINDOWS VISTA based.
Title: Correction   
Name: Keyvan Nayyeri
Date: 2006-10-27 8:36:05 AM
Actually nothing :-D

I just forgot to remove them from previous code but they won't affect the result anyways.

Thanks for pointing.
Title: grid...   
Name: Amirhossein Babaeian
Date: 2006-10-27 6:46:47 AM
what's the roll of grid.row and grid.column in controls that contains in cansvas tags?
Title: Resources in XAML   
Name: Keyvan Nayyeri
Date: 2006-10-12 12:58:22 AM
Third part of these tutorials about Resources in XAML:
Title: Nice article   
Name: Harry
Date: 2006-10-10 12:27:22 AM
Hi Keyvan,
This is very nice article about XAML. I read your previous article also, even that was alos good for begginers.

Keep it up....

Title: Introduction to XAML   
Name: Keyvan Nayyeri
Date: 2006-10-09 2:08:59 PM
First part of these tutorials, Introduction to XAML:

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-05-24 1:16:18 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search