XML
  Home arrow XML arrow Page 2 - Properties and More in XAML
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Properties and More in XAML
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2007-04-12

    Table of Contents:
  • Properties and More in XAML
  • Attached Properties
  • Binding Properties
  • Codebehind

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Properties and More in XAML - Attached Properties


    (Page 2 of 4 )

    A few XAML elements have attributes that are declared in other elements rather than in the element itself. These attributes are called attached properties. Attached properties are generally used to position elements within a parent element. Two elements with attached properties are Grid and DockPanel . Grid uses attached properties to describe the row and column in which an element should be contained. DockPanel uses attached properties to describe the location within the panel where an element should be placed.

    Attached properties can be set on any element that derives from DependencyObject . UIElement derives from DependencyObject , so the requirement is met by most XAML elements.

    Attached properties are declared in an element by using a reference to the element and the attribute being declared in the following manner: AttachPropertyProvider.PropertyName . For example, Grid has two attached properties: Row and Column . An element contained within a specific row/column combination in a grid would specify the row as an attribute with the name Grid.Row and the column similarly as Grid.Column . Example 3-14 describes the use of these attached properties.

    Example 3-14. Using the attached properties of Grid

    <Grid
        ShowGridLines="true">
        <ColumnDefinition
            
    Width="50"/>
        <ColumnDefinition
             Width="50"/>
        <RowDefinition
             Height="100" />
        <RowDefinition
             Height="25" />
        <RowDefinition
             Height="25" />
        <TextBlock
            
    Grid.Column="0"
             Grid.Row="0">Col 0, Row 0
        </TextBlock>
        <TextBlock
            
    Grid.Column="1"
           
    Grid.Row="0">Col 1, Row 0 
        </TextBlock>
       
    <TextBlock
            
    Grid.Column="0"
             Grid.Row="1">Col 0, Row 1
       
    </TextBlock>
       
    <TextBlock
            
    Grid.Column="1"
           
    Grid.Row="1">Col 1, Row 1  
        </TextBlock>
    </Grid>

    More XML Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "XAML in a Nutshell," published by...
     

    Buy this book now. This article is excerpted from the book XAML in a Nutshell, written by Lori A. MacVittie (O'Reilly, 2006; ISBN: 596526733). Check it out today at your favorite bookstore. Buy this book now.

    XML ARTICLES

    - More on Triggers and Styles and Control Temp...
    - Looking at Triggers with Styles and Control ...
    - A Closer Look at Styles and Control Templates
    - Styles and Control Templates
    - Properties and More in XAML
    - Elements and Attributes in XAML
    - XAML in a Nutshell
    - Importing XML Files into Access 2007
    - Using MSXML3.0 with VB 6.0
    - MSXML, concluded
    - MSXML, continued
    - MSXML Tutorial
    - Generating XML Schema Dynamically Using VB.N...
    - XSL Transformations using ASP.NET
    - Applying XSLT to XML Using ASP.NET





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway