XML
  Home arrow XML arrow Page 4 - Elements and Attributes 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

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

    Table of Contents:
  • Elements and Attributes in XAML
  • Document Elements
  • Attributes
  • Assigning XAML Attributes

  • 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


    Elements and Attributes in XAML - Assigning XAML Attributes


    (Page 4 of 4 )

    Regardless of their underlying types, all XAML attributes can be assigned in one of two ways. They can be assigned inline, as part of the element declaration, or they can be explicitly declared as nested elements within the element being described. As a general rule, complex attributes must be declared explicitly, while simple attributes can be defined inline, as shown in Example 3-9. Simple attributes are those whose data types are primitives, such as String , Integer , and Double . Enumerations are also declared inline, using a String representation of the name of the enumerated value. All inline attribute declarations must be enclosed in double quotes, regardless of the underlying data type of the property being described. You don’t have to enclose attributes of type String in two sets of quotes. String is sort of the exception to the rule, because it is, after all, already a String .

    Example 3-9. Inline declaration of a simple attribute

    <Button
        Content="Click Me" />

    Complex attributes are defined as a CLR class or are of type struct . They are declared explicitly, as shown in Example 3-10. In this example, GeometryDrawing has two complex attributes: Pen and Geometry . Neither attribute can be specified using abbreviated syntax, so it is necessary to explicitly declare them. The exception to this rule is the specification of child elements, which are declared by using standard XML mechanisms without the name of the attribute. This is illustrated in Example 3-10, in which two instances of EllipseGeometry are implicitly declared as children of GeometryGroup . It is not necessary to specify child elements as a complex attribute by name. Elements nested between the opening and closing tags of an element are assumed to be the children of that element and are automatically added to the appropriate container property according to the CLR class, usually the Children or InternalChildren property of the parent element.

    Example 3-10. Explicit declaration of a complex attribute

    <GeometryDrawing
        Brush="Blue" >
       
    <GeometryDrawing.Pen>
           
    <Pen
                
    Thickness="1"
                 Brush="Black" /> 
        
    </GeometryDrawing.Pen>
        <GeometryDrawing.Geometry>

             <GeometryGroup>
                
    <EllipseGeometr y
                     RadiusX="0.2"
                     RadiusY="0.45"
                     Center="0.5,0.5" />

                 <EllipseGeometry
                     RadiusX="0.45"
                     RadiusY="0.2"
                     Center="0.5,0.5" />

             </GeometryGroup>
        
    </GeometryDrawing.Geometry>
    </GeometryDrawing>

    Please check back next week for the conclusion of this article.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This article is an excerpt from the book "The Basics of XAML," published by...
     

    Buy this book now. This article is excerpted from chapter 3 of The Basics of XAML, written by Lori A. MacVittie (O'Reilly, 2006; ISBN: 0596526733). 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 4 hosted by Hostway