Building Windows 8 Custom Controls

Preview:

DESCRIPTION

Presented by Diederik Krols at the Windows App Day in Antwerp, Belgium on November 23, 2012.

Citation preview

Building Win8 Custom ControlsDiederik Krols

@diederikkrolsdiederik@u2uconsult.com

The Win8 Toolbox Gap

Building your own controls

Custom ControlsUser ControlsDerived ControlsExtended Controls

Agenda

The Win8 Toolbox Gap

The Win8 Toolbox Gap

Building your own controls

Building your own controlsCustom ControlsUser ControlsDerived ControlsExtended Controls

Attached PropertiesAttached Behaviors

Custom Controls

Custom ControlA control that

provides a generic.xaml, can be styled/templated, and is usually encapsulated in its own assembly.

Creating a Custom ControlDemo

Custom Control AspectsState

Dependency PropertiesStyle

Template PartsVisual State Manager

BehaviorMethodsEvents

Custom Control PropertiesDependency Properties

Dependency PropertiesDemo

Styling a Custom ControlAnatomy of a Slider

Visual States of a SliderEnabledDisabled

Styling a Custom ControlTemplate Parts and Visual State Manager

Templating Sample

http://www.zagstudio.com/blog/470#.UKvBmug1jIV

Styling and TemplatingDemo

Custom Control BehaviorMethods and Events

Event and Event HandlerDemo

Radial Gauge Custom Control

Radial Gauge Custom ControlDemo

Some differences with other XAML platformsSay goodbye to

RadialGradientBrushTileBrushImageBrush.TileModeVisualBrushMultiBindingBinding.StringFormatBinding.Relativesource.Ancestor

User Controls

User ControlsA control that

encapsulates related existing controls, andprovides its own logic.

Creating a User ControlDemo

Enhanced Slider

Enhanced Slider User ControlDemo

XAML Page is also a User Control

Derived Controls

Derived ControlA control that

is derived from a control classother than Control or UserControl.

Derived or Inherited Control

Callisto Dynamic TextBlockDemo

Extended Controls

Extended ControlA control that

is extended by a separate classwithout creating a new control subclass.

TechniquesAttached PropertiesBehaviors

Attached PropertiesAttached Properties allow to

describe properties in separate class, andattach these to XAML elements.

ExamplesGrid.RowCanvas.Left

WinRT XAML Toolkit

TextBox Validation Extensions

Demo

BehaviorsBehaviors

are attached propertiescombined with event handlers.

‘Select All on Focus’ Behavior

Demo

SummaryThe Win8 Toolbox Gap

Building your own controlsCustom ControlsUser ControlsDerived ControlsExtended Controls

Build apps on Windows. Discover your new home.

http://msdn.be/apps

THANK YOUDiederik Krols

@diederikkrolshttp://blogs.u2u.be/

diederikdiederik@u2uconsult.com

Recommended