SlideShare a Scribd company logo
1 of 16
Week 3 - Input Handling
Jim LaVine
jim.lavine @gmail.com
Agenda
• Mouse
• Touch
• Keyboard
• Event Bubbling
• Controls
• Introduction to Expression Blend
Code Behind<UserControl x:class="MyApp.Page">
xmlns:="http://schemas.microsoft.com/client/2007/"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<Grid x:Name="LayoutRoot" Background="White">
<TextBlock x:Name="messageTextBlock"/>
</Grid>
</UserControl>
Public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
this.MouseLeftButtonDown += PageClick;
}
void PageClick(object sender, MouseButtonEventArgs e)
{
Point mousePos = e.GetPosition.this;
messageTextBlock.Text = “Click at: “ + mousePos;
}
}
Input Types
• Mouse
• Keyboard
• Touch
– Raw input only (no gestures) on non-mobile applications
– Windows phone has some gesture support
Mouse Input Events
Movement
MouseMove
MouseEnter
MouseLeave
LostMouseCapture
Mouse Button
MouseLeftButtonDown
MouseLeftButtonUp
MouseRightButtonDown
MouseRightButtonUp
Wheel
MouseWheel
MouseEventArgs
MouseWheelEventArgs
MouseButtonEventArgs
Event Bubbling
• Events Bubble up the XAML Tree
– They do not bubble into the HTML tree
• Origin indicated by OriginalSource
• Set Handled=true to halt bubbling
• No tunneling
– No Preview events
• Intrinsic events only
Mouse Capture
• Mouse can move out of element
– What if we still want events
• Capture mouse events
• Should release capture when done
– May get early LostMouseCapture
Right Mouse Button
• New in Silverlight 4
• No built-in custom context menu
– April 2010 Silverlight toolkit provides one: http://silverlight.codeplex.com/
Silverlight
Mouse Wheel
• Platform=specific oddities
– NPAPI Limitations
– No Mac Support
• HTML DOM may work
– No OOB
Touch
• Touch input as mouse substitute
• Touch aware code
– Can handle multi-touch
– Specialized touch-based interaction
• Touch.FrameReported event
– GetTouchPoints
– GetPrimaryTouchPoint
– SuspendMousePromotionUntilTouchUp
• Gestures on Windows Phone 7 only
Keyboard
• KeyUp and KeyDown events
– KeyEventArgs.Key
– KeyEventArgs.PlatformKeyCode
• Focus
– Plug-in model makes this slightly messy
– Only Control-derived classes can receive focus
Controls
• Textual input with TextBox
– Globalized
– Accessible
– Data bindable
• Button
– Accessible
Introduction to
Expression Blend
• The development environment
• Resources & Styles
• Customize controls
• Applying animation
Reference Links
• http://channel9.msdn.com/shows/SilverlightTV/
• http://www.silverlight.net/learn/videos/expression/
• http://www.microsoft.com/design/toolbox/
• http://expression.microsoft.com/en-
us/cc136522.aspx
Target Applications
• WPF & Silverlight
• Sketchflow
Summary
• Mouse
• Touch
• Keyboard
• Event Bubbling
• Controls
• Expression Blend

More Related Content

Similar to Silverlight Input Handling

follow-app BOOTCAMP 2: Introduction to silverlight
follow-app BOOTCAMP 2: Introduction to silverlightfollow-app BOOTCAMP 2: Introduction to silverlight
follow-app BOOTCAMP 2: Introduction to silverlightQIRIS
 
Introj Query Pt2
Introj Query Pt2Introj Query Pt2
Introj Query Pt2kshyju
 
Introduction to Silverlight
Introduction to SilverlightIntroduction to Silverlight
Introduction to SilverlightEd Donahue
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
20150812  4시간만에 따라해보는 windows 10 앱 개발20150812  4시간만에 따라해보는 windows 10 앱 개발
20150812 4시간만에 따라해보는 windows 10 앱 개발영욱 김
 
Session iii(server controls)
Session iii(server controls)Session iii(server controls)
Session iii(server controls)Shrijan Tiwari
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events WebStackAcademy
 
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMPROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMSaraswathiRamalingam
 
5 .java script events
5 .java script   events5 .java script   events
5 .java script eventschauhankapil
 
types of events in JS
types of events in JS types of events in JS
types of events in JS chauhankapil
 
Multi Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesMulti Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesEthan Cha
 
ADF Mobile - an intro for Developers
ADF Mobile - an intro for DevelopersADF Mobile - an intro for Developers
ADF Mobile - an intro for DevelopersLuc Bors
 
cse581_03_EventProgramming.ppt
cse581_03_EventProgramming.pptcse581_03_EventProgramming.ppt
cse581_03_EventProgramming.ppttadudemise
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intentPERKYTORIALS
 
Building Native Experiences with Electron
Building Native Experiences with ElectronBuilding Native Experiences with Electron
Building Native Experiences with ElectronBen Gotow
 
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.154.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15Rajes Wari
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptsharanyak0721
 

Similar to Silverlight Input Handling (20)

follow-app BOOTCAMP 2: Introduction to silverlight
follow-app BOOTCAMP 2: Introduction to silverlightfollow-app BOOTCAMP 2: Introduction to silverlight
follow-app BOOTCAMP 2: Introduction to silverlight
 
Introj Query Pt2
Introj Query Pt2Introj Query Pt2
Introj Query Pt2
 
Introduction to Silverlight
Introduction to SilverlightIntroduction to Silverlight
Introduction to Silverlight
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
20150812  4시간만에 따라해보는 windows 10 앱 개발20150812  4시간만에 따라해보는 windows 10 앱 개발
20150812 4시간만에 따라해보는 windows 10 앱 개발
 
Session iii(server controls)
Session iii(server controls)Session iii(server controls)
Session iii(server controls)
 
Geb qa fest2017
Geb qa fest2017Geb qa fest2017
Geb qa fest2017
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMPROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
 
Java-Events
Java-EventsJava-Events
Java-Events
 
Android Button
Android ButtonAndroid Button
Android Button
 
5 .java script events
5 .java script   events5 .java script   events
5 .java script events
 
types of events in JS
types of events in JS types of events in JS
types of events in JS
 
Multi Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesMulti Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And Types
 
ADF Mobile - an intro for Developers
ADF Mobile - an intro for DevelopersADF Mobile - an intro for Developers
ADF Mobile - an intro for Developers
 
cse581_03_EventProgramming.ppt
cse581_03_EventProgramming.pptcse581_03_EventProgramming.ppt
cse581_03_EventProgramming.ppt
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intent
 
Building Native Experiences with Electron
Building Native Experiences with ElectronBuilding Native Experiences with Electron
Building Native Experiences with Electron
 
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.154.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
 

Silverlight Input Handling

Editor's Notes

  1. There are several ways for a user to interact with your application. The most obvious way is with the mouse. Silverlight offers event to track mouse and button movement as well as wheel activity. There is also the keyboard of course. Silverlight also supports touch screen events
  2. Mouse events happen when the mouse is over the object and not its bounding box. You only get mouse events in the area that has been painted with a brush. Use the IsHitTestVisible property to ignore events.