Using XAML in Windows Presentation Foundation
(Extensible Application mark-up Language) is a declarative language. It is similar
to ASP.NET 2.0 web page definition using HTML tags. It defines the managed object
instantiation. These files have .xaml extension. You can use XAML to write WPF
applications. You should understand the elements, the properties, attributes of
the elements and other aspects of XAML to create applications.
root elements for the XAML files are:
XAML code behind:
XAML code behind:
The above C# code is defined separately. This file is called code behind file. When compiling the .xaml the compiler also include the code behind file.
Attached properties and attached events
element can specify any property, even if it does not exist in that element.
ownerType.propName = value
Attached events use syntax like ownerType.eventName. An example for attached event is Mouse. MouseDown.
But for elements derived from the UIElement or ContentElement, attached event syntax is not must, because the base class creates alias for these important input events.
Syntax and grammar
XAML is case sensitive. The XML loader will drop extra white spaces.
A class might support the usage of it as an element in the XAML file. But it must be placed properly under the page or application elements. For example, MenuItem must be placed inside Menu element.
The content property values must be continuous. Child elements must be continuous.
Typeconverter-Enabled Attribute Values allows values for attribute to be specified in string format. For example, the margin property can be specified as single string. This avoids using lengthy property syntax for defining complex property.
Margin="10,20,10,30" Content="Click me"/>
Syntax for Attribute
<Button Background="Blue" Foreground="Red" Content="This is a button"/>
Syntax for Property Element
Collection Types and XAML Collection Properties
element on a page that is nested as a child element of another element can be
can find a lot of tutorials on building an XAML application in the web. You can
use the above concepts to create your own XAML application.
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________
Visit .NET Programming Tutorial Homepage