200 likes | 515 Views
XAML. XAML - definition. Extensible Application Markup Language Declarative language XAML is used to construct and initializing .NET objects XAML is only interesting together with an API ( Silverlight /WPF) Everything we can do in XAML, we can also do in .NET code. XAML Namespaces.
E N D
XAML - definition Extensible Application Markup Language Declarative language XAML is used to construct and initializing .NET objects XAML is only interesting together with an API (Silverlight/WPF) Everything we can do in XAML, we can also do in .NET code
XAML Namespaces Default namespacexmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Secondary namespacexmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Reference namespaces in same assemblyxmlns:local="clr-namespace:MyProject" Reference namespace in external assemblyxmlns:myLib="clr-namespace:MyNamespace;assembly=MyLibrary"
Child Objects Declaring objects inside another object
ChildObjects The Content Property
Attribute Syntax The default way to set a property in XAML
Content Element Syntax Some object allow content to be set directly without specifying the property name
Property Element Syntax The Property element syntax is used when we need to nest more complex definitions inside a property
Collection Syntax The collection syntax adds object to a collection
MarkupExtensions A Markup Extension is a class that decides at runtime how to set a property’s value Build-in Markup Extensions in Silverlight- Binding- StaticResource- TemplateBinding- NullExtension
The Binding Extension The Binding Extension is used for data binding
The StaticResourceExtension The StaticResourceExtention returns the value of the specified resource. This is a one-time resource lookup
The TemplateBindingExtension Links the value of a property in a control template to the value of some other exposed property on the templated control.
NullExtension Setting a value to null in XAML
Code behind XAML supports code behind through partial classes When the x:class attribute is defined, the XAML compiler will generate a partial class from the markup
Events in XAML Two ways to attach event handlers- attach in XAML or- attach in the Code Behind
WPF Compatibility MarkupExtensions differences- x:TypeExtensiion- x:ArrayExtension- x:Static- DynamicResourceExtension- RelativeSourceExtension CustomMarkupExtensions