ROUTED EVENTS. Chapter 5 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon

Similar documents
LAYOUT. Chapter 3 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon

XAML. Chapter 2 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon Understanding XAML

STYLES AND BEHAVIORS

SHAPES & TRANSFORMS. Chapter 12 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ.

SMART Meeting Pro 4.2 personal license USER S GUIDE

SMART Meeting Pro PE 4.1 software

Solving the Windows 8 Puzzle

Controlling Windows with gestures

Beginning Silverlight 5 in C #

Tetra4D Reviewer. Version 5.1. User Guide. Details on how to use Tetra4D Reviewer.

Lifespan Guide for installing and using Citrix Receiver on your Mobile Device

CS3240 Human-Computer Interaction Lab Sheet Lab Session 2

Developing for touch. Peter-Paul Koch Mobilism, 16 and 17 May 2013

How to Get Started. Figure 3

Building Responsive Apps for Windows 10 Greg Lutz. GrapeCity

Event Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. Event Architecture. A pipeline: Event Capture

Lesson 1: Exploring Excel Return to the Excel 2007 web page

Event Dispatch. Dispatching events to windows and widgets.

Exploring Windows 10. Start menu. Display the Start menu. Microsoft IT Showcase

Introduction p. 1 Who Should Read This Book? p. 2 Software Requirements p. 3 Code Examples p. 3 How This Book Is Organized p. 4 Conventions Used in

WINDOWS 8 CHEAT SHEET

DOT.NET MODULE 6: SILVERLIGHT

S A M P L E C H A P T E R

DOWNLOADING OFFICE 365 TO YOUR HOME COMPUTER

Explore Windows 8.1 Update

Is image everything?

Getting Started Create Your First Notebook

MindBoard 2 User Guide. Tomoaki Oshima

COMP30019 Graphics and Interaction Input

PART I: INTRODUCTION TO WINDOWS 8 APPLICATION DEVELOPMENT CHAPTER 1: A BRIEF HISTORY OF WINDOWS APPLICATION DEVELOPMENT 3

Ultrabook Convertible Application Design Considerations

Clip Art and Graphics. Inserting Clip Art. Inserting Other Graphics. Creating Your Own Shapes. Formatting the Shape

Windows Presentation Foundation for.net Developers

Event Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. 2.4 Event Dispatch 1

What is Emcee? Actions in Thumbnail View Starting Emcee and Activating the Thumbnail View... 5

HOUR 4 Understanding Events

SmartBoard & Smart Notebook Software

Mobile 3.1 ios & Android v2

Getting to Know Windows 10. Handout

Computer Basics. Need more help? What s in this guide? Types of computers and basic parts. Why learn to use a computer?

Multi-touch Technology: Intuitive Functionality Advances Automation

WPF and MVVM Study Guides

XPEL DAP SUPPORT. DAP Tool List & Overview DESCRIPTION ICON/TOOL (SHORTCUT)

Mobile: OneNote. Microsoft Quick Start ITS (2017)

WACOM GESTURE GUIDE: USING TOUCH WITH WACOM TABLETS

5/19/2015. Objectives. JavaScript, Sixth Edition. Using Touch Events and Pointer Events. Creating a Drag-and Drop Application with Mouse Events

Windows Presentation Foundation

Windows Presentation Foundation. Jim Fawcett CSE687 Object Oriented Design Spring 2018

CPSC 481 Tutorial 10 Expression Blend. Brennan Jones (based on tutorials by Bon Adriel Aseniero and David Ledo)

GET STARTED WITH GOODNOTES USER GUIDE

Part 1: Basics. Page Sorter:

Quick Start Guide. Microsoft Visio 2013 looks different from previous versions, so we created this guide to help you minimize the learning curve.

Interaction Style Categories. COSC 3461 User Interfaces. Windows. Window Manager

Exploring Windows 10. Work Smart by Microsoft IT. Topics in this guide include: Snap enhancements. Notification center. For more information

Programming Windows, Sixth Edition

BCIS 4650 Visual Programming for Business Applications

SMART Ink 1.5. Mac OS X operating system software. Scan the following QR code to view the SMART Ink Help on your smart phone or other mobile device.

Microsoft Surface Pro 2 Windows 8 tablet - basic notes for staff

Your familiar Windows, only better.

Microsoft Publisher 2010 Tecumseh District Library

Center for Faculty Development and Support Creating Powerful and Accessible Presentation

Tap on "Notebooks" button (in portrait mode) to start a new notebook.

Primal s 3D Anatomy and Physiology

Remote Desktop Services Guide. Android DG ITEC ESIO - STANDARDS

DW DIGs Model Windows Tricks

Quick Start Guide. Microsoft OneNote 2013 looks different from previous versions, so we created this guide to help you minimize the learning curve.

Chapter 10 Working with Graphs and Charts

Microsoft IT Showcase. microsoft.com/itshowcase

CREATING A POWERPOINT PRESENTATION BASIC INSTRUCTIONS

Hell is other browsers - Sartre. The touch events. Peter-Paul Koch (ppk) WebExpo, 24 September 2010

User Guide pdoc Signer for Apple ipad

OnPoint s Guide to MimioStudio 9

PRESENTED BY: M.NAVEEN KUMAR 08M31A05A7

better if the document has a good contrast to the background and all edges are clearly visible. A white document on a white table would be difficult

Your Total Training Resource. Microsoft OneNote. To Schedule / Need Additional Information

Ript User Guide (v )

End User Guide. 2.1 Getting Started Toolbar Right-click Contextual Menu Navigation Panels... 2

Lab 2. CSE 3, Summer 2010 In this lab you will learn about file structures and advanced features of Microsoft Word.

with TestComplete 12 Desktop, Web, and Mobile Testing Tutorials

Adobe Acrobat Training

Road Map for Essential Studio 2010 Volume 1

StitchSketch User s Manual

Mouse Basics. Dayton Metro Library

EXAMGOOD QUESTION & ANSWER. Accurate study guides High passing rate! Exam Good provides update free of charge in one year!

GraphWorX64 Productivity Tips

Today s Hall of Fame or Shame example is a feature of Microsoft Office 2007 that gives a preview of what a style command will do to the document

Text Box Frames. Format Text Box

7 For Seniors For Dummies

Help us make this document better smarttech.com/docfeedback/ SMART Ink 3.1 USER S GUIDE FOR WINDOWS OPERATING SYSTEMS

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

Anatomy of a Window (Windows 7, Office 2010)

Opening and Using Programs

Part II: Creating Visio Drawings

LCD MONITOR TOUCH PANEL DRIVER 2 OPERATION MANUAL. for Mac. Version 2.2

Was this document helpful? smarttech.com/docfeedback/ SMART Ink 5.2 USER S GUIDE

Lost Pet Poster. Assignment

For the Beginner: c) Click the settings tab to set screen resolution d) Set resolution with slider bar.

CHAPTER 1: INTRODUCING C# 3

SMART Meeting Pro 4.1 software

Digital Literacy. Identify types of computers, how they process information, and the purpose and function of different hardware components

Transcription:

ROUTED EVENTS Chapter 5 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon - 2014 Introduction Routed events are events with more traveling power they can tunnel down or bubble up the element tree and be processed by event handlers along the way. A routed event can be handled on one element (such as a label) even though it originates on another (such as an image inside that label). 1

Introduction Every.NET developer is familiar with the idea of events messages that are sent by an object. WPF enhances the.net event model with the concept of event routing. Event routing allows an event to originate in one element but be raised by another one. For example, event routing allows a click that begins in a toolbar button to rise up to the toolbar and then to the containing window before it s handled by your code. Introduction 2

Event Routing Many controls in WPF are content controls, and content controls can hold any type and amount of nested content. For example, you can build a graphical button out of shapes, create a label that mixes text and pictures, or put content in a specialized container to get a scrollable or collapsible display. You can even repeat this nesting process to go as many layers deep as you want. Event Routing imagine you have a label like this one, which contains a StackPanel that brings together two blocks of text and an image consider what happens when you click the image part of the fancy label shown here. Clearly, it makes sense for the Image.MouseDown and Image.MouseUp events to fire. But what if you want to treat all label clicks in the same way? 3

Routed events come in the following three flavors: Direct events: These are like ordinary.net events. They originate in one element and don t pass to any other. For example, MouseEnter (which fires when the mouse pointer moves over an eleent) is a direct event. Bubbling events: These events travel up the containment hierarchy. For example, MouseDown is a bubbling event. It s raised first by the element that is clicked. Next, it s raised by that element s parent, then by that element s parent, and so on, until WPF reaches the top of the element tree. Routed events come in the following three flavors: Tunneling events These events travel down the containment hierarchy. They give you the chance to preview (and possibly stop) an event before it reaches the appropriate control. For example, PreviewKeyDown allows you to intercept a key press, first at the window level and then in increasingly more-specific containers until you reach the element that had focus when the key was pressed. Example p111-113 on your textbook. 4

Attached Events many controls have their own more specialized events. The button is one example it adds a Click event that isn t defined by any base class. Imagine that you wrap a stack of buttons in a StackPanel. You want to handle all the button clicks in one event handler. You can handle all the button clicks by handling the Click event at a higher level (such as the containing StackPanel). Attached Events The problem is that the StackPanel doesn t include a Click event, so this is interpreted by the XAML parser as an error. The solution is to use a different attached-event syntax in the form ClassName.EventName. 5

Attached Events In the DoSomething() event handler, you have several options for determining which button fired the event. You can compare its text (which will cause problems for localization) or its name (which is fragile because you won t catch mistyped names when you build the application). Tunneling Events Tunneling events work the same as bubbling events but in the opposite direction. For example, If MouseUp was a tunneled event (which it isn t), clicking the image in the fancy label example would cause MouseUp to fire first in the window, then in the Grid, then in the StackPanel, and so on, until it reaches the actual source, which is the image in the label. 6

Tunneling Events Tunneling events are easy to recognize because they begin with the word Preview. Furthermore, WPF usually defines bubbling and tunneling events in pairs. That means if you find a bubbling MouseUp event, you can probably also find a tunneling PreviewMouseUp event. Tunneling Events 7

Tunneling Events Tunneling events are useful if you need to perform some preprocessing that acts on certain keystrokes or filters out certain mouse actions. WPF Events The most important events usually fall into one of five categories: Lifetime events: These events occur when the element is initialized, loaded, or unloaded. Mouse events: These events are the result of mouse actions. Keyboard events: These events are the result of keyboard actions (such as key presses). Stylus events: These events are the result of using the pen-like stylus, which takes the place of a mouse on a Tablet PC. Multitouch events: These events are the result of touching down with one or more fingers on a multitouch screen. They re supported only in Windows 7 and Windows 8. 8

Multitouch Input Multitouch is a way of interacting with an application by touching a screen. What distinguishes multitouch input from old-fashioned pen input is that multitouch recognizes gestures specific ways the user can move more than one finger to perform a common operation. Multitouch Input A simple multitouch enabled application might show multiple pictures on a virtual desktop and allow the user to drag, resize, and rotate each image to create a new arrangement. 9

Multitouch : WPF provides three layers of multitouch support: Raw touch: This is the lowest level of support, and it gives you access to every touch the user makes. Manipulation: This is a convenient abstraction that translates raw multitouch input into meaningful gestures.the common gestures that WPF elements support include pan, zoom, rotate, and tap. Built-in element support: Some elements already react to multitouch events, with no code required. For example, scrollable controls such as the ListBox, ListView, DataGrid, TextBox, and ScrollViewer support touch panning. Raw Touch 10

Raw Touch What distinguishes this example from a similar mouse event test is that the user can touch down with several fingers at once, causing multiple ellipses to appear, each of which can be dragged about independently. Exampl p134-136 Manipulation + Inertia Sunday s Next Seminar 11