
Using XAML in Windows Presentation FoundationXAML
(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.
The
root elements for the XAML files are: XAML
code behind: XAML
code behind: <Page
namespace
SampleNameSpace 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 An
element can specify any property, even if it does not exist in that element. ownerType.propName
= value Example: 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. <Button
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 <Button> Collection
Types and XAML Collection Properties Object
element on a page that is nested as a child element of another element can be Markup
Extensions You
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.
_______________________________________________________________________
FREE
Subscription
Subscribe
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________ |