Anda di halaman 1dari 14

WPF

What is WPF?
Windows Presentation Framework is a two and three dimensional graphics
engine providing the following capabilities:
Has all equivalent common user controls like buttons, check boxes, sliders, etc.
Fixed and flow format documents.
Has all of the capabilities of HTML and Flash.
2D and 3D vector graphics.
Animation.
Multimedia.
Data binding.

What is XAML?
XAML (Extensible Application Mark-up Language) is a declarative XMLbased language by which you can define objects and properties in XML.
The XAML Parser loads the XAML document and create the actual object
while it renders the application.
It is used to create any kind of objects, graphical or non-graphical
interfaces.
It has many variants and can be used with WPF, Silverlight and WWF.

WPF Architecture
WPF is a set of assemblies that build
up the entire framework. These
assemblies can be categorized as:
Managed Layer
UnManaged Layer
Core API

Managed Layer
Managed layer of WPF is built using a number of assemblies. These
assemblies build up the WPF framework, communicate with lower level
unmanaged API to render its content. The few assemblies that comprise the
WPF framework are:
PresentationFramework.dll: Creates the top level elements like layout
panels, controls, windows, styles, etc.
PresentationCore.dll: It holds base types such as UIElement, Visual from
which all shapes and controls are Derived in PresentationFramework.dll.
WindowsBase.dll: They hold even more basic elements which are capable
of being used outside the WPF environment like Dispatcher object,
Dependency Objects.

Unmanaged Layer
milcore.dll: The unmanaged layer of WPF is called milcore or Media
Integration Library Core. It basically translates the WPF higher level objects
like layout panels, buttons, animation, etc. into textures
that Direct3D expects. It is the main rendering engine of WPF.
WindowsCodecs.dll: This is another low level API which is used for imaging
support in WPF applications.WindowsCodecs.dll comprises a number of
codecs which encode / decode images into vector graphics that would be
rendered into WPF screen.
Direct3D: It is the low level API in which the graphics of WPF is rendered.
User32: It is the primary core API which every program uses. It actually
manages memory and process separation.
GDI & Device Drivers: GDI and Device Drivers are specific to the operating
system which is also used from the application to access low level APIs.

Logical Tree and Visual Tree?

Logical tree compromises the elements as they are listed in XAML. They
only include the controls declared.
Visual tree comprises the parts that make up the individual controls. It is an
expansion of a logical tree, in which nodes are broken down into their core
visual components.
The elements that derive from System.Windows.Media.Visual or
System.Windows.Media.Visual3D are included in the Visual tree.
Logical & Visual trees help in designing the properties, events, resources,
styling etc.

Dependency Properties
WPF introduces a new type of property called a dependency property that
is used throughout the platform to enable styling, automatic data binding,
animation, and more.
Every WPF control is derived from DependencyObject class and hence
can associate itself in various inbuilt features of WPF like Event Triggers,
Property Bindings, Animations etc.
A dependency property depends on multiple providers for determining its
value at any point in time.
The features of dependency properties are:
. Change notification
. Property value inheritance
. Support for multiple providers

Routed Events
Routed events are events that are designed to work well with a tree of
elements.
When a routed event is registered, it is invoked, it Bubbles/Tunnels
through the Visual Elements and calls all the registered
RoutedEventHandlers associated with the Visual Tree one by one.
To discriminate between the two, WPF demarcated events with
Preview*** as the events which are Tunneled and just *** for the
events that Bubbles.
Ex: Tunneling Event : IsPreviewMouseDown
Bubbling Event : MouseDown

Object Hierarchy
DispatcherObject: Mother of all WPF controls which takes care of UI
thread
DependencyObject: Builds the Observer for Dependency Properties
Visual: Links between managed libraries and milcore.
UIElement: Adds supports for WPF features like layout, input, events, etc.
FrameworkElement: Implementation of UIElement.
Shape: Base class of all the Basic Shapes.
Control: The UI elements that interact with the user. They can be
Templated to change look.
ContentControl: Baseclass of all controls that have single content.
ItemsControl: Baseclass for all controls that show a collection.
Panel: Baseclass of all panels which show one or more controls within it.

UI Layouts
WPF contains five built-in panels that are derived from
System.Windows.Controls namespace
1. Canvas- allows the positioning of elements with explicit coordinates.
2. StackPanel stacks the elements either horizontally or vertically through
Orientation property. Default orientation is Vertical.
3. WrapPanel same as stack panel , in addition wraps them to additions
rows or columns when there is not enough space for single stack.
4. DockPanel - enables easy docking of elements to an entire side of the
panel, stretching it to fill the entire width or height
5. Grid most versatile and widely used layout. It enables to arrange
children in a multirow and column fashion.
Note: These give the ability to create table like layouts.

Data Binding, Styles, Triggers,


Resources
WPF provides 5 data binding modes

Default
One Way to Source Reverse of One Way.
One Time one time binding from Source to Target, but no updates from source later.
One Way from Source to Target
Two Way changes to Source and Target are copied to each other.

Styles are categorized into Implicit & Explicit Styles.


Triggers are set of styles that work on particular conditions. They are
categorized into
Property Trigger
Data Trigger
Event Trigger

Resource Dictionary is a placeholder for custom styles, Data templates,


Control Templates and lot more.

Questions?

Anda mungkin juga menyukai