Top Banner
Building Win8 Custom Controls Diederik Krols @diederikkrols diederik@u2uconsult .com
40

Building Windows 8 Custom Controls

Dec 18, 2014

Download

Documents

Presented by Diederik Krols at the Windows App Day in Antwerp, Belgium on November 23, 2012.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building Windows 8 Custom Controls

Building Win8 Custom ControlsDiederik Krols

@[email protected]

Page 2: Building Windows 8 Custom Controls

The Win8 Toolbox Gap

Building your own controls

Custom ControlsUser ControlsDerived ControlsExtended Controls

Agenda

Page 3: Building Windows 8 Custom Controls

The Win8 Toolbox Gap

Page 4: Building Windows 8 Custom Controls

The Win8 Toolbox Gap

Page 5: Building Windows 8 Custom Controls

Building your own controls

Page 6: Building Windows 8 Custom Controls

Building your own controlsCustom ControlsUser ControlsDerived ControlsExtended Controls

Attached PropertiesAttached Behaviors

Page 7: Building Windows 8 Custom Controls

Custom Controls

Page 8: Building Windows 8 Custom Controls

Custom ControlA control that

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

Page 9: Building Windows 8 Custom Controls

Creating a Custom ControlDemo

Page 10: Building Windows 8 Custom Controls

Custom Control AspectsState

Dependency PropertiesStyle

Template PartsVisual State Manager

BehaviorMethodsEvents

Page 11: Building Windows 8 Custom Controls

Custom Control PropertiesDependency Properties

Page 12: Building Windows 8 Custom Controls

Dependency PropertiesDemo

Page 13: Building Windows 8 Custom Controls

Styling a Custom ControlAnatomy of a Slider

Visual States of a SliderEnabledDisabled

Page 14: Building Windows 8 Custom Controls

Styling a Custom ControlTemplate Parts and Visual State Manager

Page 15: Building Windows 8 Custom Controls

Templating Sample

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

Page 16: Building Windows 8 Custom Controls

Styling and TemplatingDemo

Page 17: Building Windows 8 Custom Controls

Custom Control BehaviorMethods and Events

Page 18: Building Windows 8 Custom Controls

Event and Event HandlerDemo

Page 19: Building Windows 8 Custom Controls

Radial Gauge Custom Control

Page 20: Building Windows 8 Custom Controls

Radial Gauge Custom ControlDemo

Page 21: Building Windows 8 Custom Controls

Some differences with other XAML platformsSay goodbye to

RadialGradientBrushTileBrushImageBrush.TileModeVisualBrushMultiBindingBinding.StringFormatBinding.Relativesource.Ancestor

Page 22: Building Windows 8 Custom Controls

User Controls

Page 23: Building Windows 8 Custom Controls

User ControlsA control that

encapsulates related existing controls, andprovides its own logic.

Page 24: Building Windows 8 Custom Controls

Creating a User ControlDemo

Page 25: Building Windows 8 Custom Controls

Enhanced Slider

Page 26: Building Windows 8 Custom Controls

Enhanced Slider User ControlDemo

Page 27: Building Windows 8 Custom Controls

XAML Page is also a User Control

Page 28: Building Windows 8 Custom Controls

Derived Controls

Page 29: Building Windows 8 Custom Controls

Derived ControlA control that

is derived from a control classother than Control or UserControl.

Page 30: Building Windows 8 Custom Controls

Derived or Inherited Control

Page 31: Building Windows 8 Custom Controls

Callisto Dynamic TextBlockDemo

Page 32: Building Windows 8 Custom Controls

Extended Controls

Page 33: Building Windows 8 Custom Controls

Extended ControlA control that

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

TechniquesAttached PropertiesBehaviors

Page 34: Building Windows 8 Custom Controls

Attached PropertiesAttached Properties allow to

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

ExamplesGrid.RowCanvas.Left

Page 35: Building Windows 8 Custom Controls

WinRT XAML Toolkit

TextBox Validation Extensions

Demo

Page 36: Building Windows 8 Custom Controls

BehaviorsBehaviors

are attached propertiescombined with event handlers.

Page 37: Building Windows 8 Custom Controls

‘Select All on Focus’ Behavior

Demo

Page 38: Building Windows 8 Custom Controls

SummaryThe Win8 Toolbox Gap

Building your own controlsCustom ControlsUser ControlsDerived ControlsExtended Controls

Page 39: Building Windows 8 Custom Controls

Build apps on Windows. Discover your new home.

http://msdn.be/apps

Page 40: Building Windows 8 Custom Controls

THANK YOUDiederik Krols

@diederikkrolshttp://blogs.u2u.be/

[email protected]