Add new scenarios to Input sample (PointerTracking, PointerPointProperties, DeviceCapabilities, XamlManipulations)#650
Open
qiutongMS wants to merge 4 commits into
Conversation
Migrated from windows-topic-specific-samples (uwp-pointers + uwp-pointers-animation). - Multi-pointer tracking with Canvas visualization - Primary pointer detection with animated Ellipse (Storyboard) - Handles all pointer lifecycle events Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… scenarios - PointerPointProperties: shows pointer info (mouse buttons, pen pressure, touch contact rect) on click/touch with color-coded display - DeviceCapabilities: displays keyboard, mouse, and touch device capabilities - XamlManipulations: demonstrates ManipulationMode with translate, rotate, and inertia controls - Fix Canvas Background='Transparent' for hit-test in PointerPointProperties - Add Landscape.jpg to Content items for GestureRecognizerManipulation scenario - Reorder launchSettings.json to default to Unpackaged profile Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the Input (cs-winui) sample by adding new scenario pages demonstrating pointer tracking, pointer point properties, device capability detection, and XAML manipulation interactions, aligning the sample with scenarios referenced by Microsoft Learn input documentation.
Changes:
- Added new scenario pages: PointerTracking, Pointer Point Properties, Device Capabilities, and XAML Manipulations, plus a shared PointerEllipse control.
- Updated scenario registration so the new pages appear in the sample’s navigation list.
- Updated the project to include required content/assets and ensured new XAML pages are compiled.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Samples/Input/cs-winui/XamlManipulations.xaml.cs | Adds code-behind for manipulation transforms, options, and reset behavior. |
| Samples/Input/cs-winui/XamlManipulations.xaml | Adds UI for manipulation scenario (axis selection, inertia toggle, reset, target element). |
| Samples/Input/cs-winui/SampleConfiguration.cs | Registers the new scenarios in the app’s scenario list. |
| Samples/Input/cs-winui/Properties/launchSettings.json | Reorders/normalizes debug profiles for packaged vs unpackaged runs. |
| Samples/Input/cs-winui/PointerTracking.xaml.cs | Implements multi-pointer tracking logic and UI updates. |
| Samples/Input/cs-winui/PointerTracking.xaml | Defines UI for pointer tracking canvas and status readouts. |
| Samples/Input/cs-winui/PointerPointProperties.xaml.cs | Implements pointer property popups and device-specific property rendering. |
| Samples/Input/cs-winui/PointerPointProperties.xaml | Defines UI surface for pointer property display interactions. |
| Samples/Input/cs-winui/PointerEllipse.xaml.cs | Adds a reusable pointer visualization control with primary/secondary styling. |
| Samples/Input/cs-winui/PointerEllipse.xaml | Defines the animated ellipse storyboard and visuals for pointer feedback. |
| Samples/Input/cs-winui/Input.csproj | Includes new pages/assets (including Landscape.jpg) and ensures new XAML pages compile. |
| Samples/Input/cs-winui/DeviceCapabilities.xaml.cs | Implements device capability reporting using Keyboard/Mouse/TouchCapabilities. |
| Samples/Input/cs-winui/DeviceCapabilities.xaml | Defines UI for displaying capability results and scenario description. |
- Add UTF-8 BOM to all new .cs files per .editorconfig requirement - Replace XOR toggle with explicit set/clear for inertia ManipulationMode flags Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines
+39
to
+49
| private void OnPointerMoved(object sender, PointerRoutedEventArgs e) | ||
| { | ||
| PointerPoint pointerPoint = e.GetCurrentPoint(pointerCanvas); | ||
| if (ellipses.TryGetValue(pointerPoint.PointerId, out PointerEllipse ellipse)) | ||
| { | ||
| UpdateEllipsePosition(ellipse, pointerPoint.Position); | ||
| UpdateLastEvent("Moved", pointerPoint.PointerId); | ||
| } | ||
|
|
||
| e.Handled = true; | ||
| } |
Comment on lines
+36
to
+49
| private void ApplyPointerStyle(bool isPrimary) | ||
| { | ||
| if (isPrimary) | ||
| { | ||
| ellipse.Fill = new SolidColorBrush(Colors.White); | ||
| ellipse.Stroke = new SolidColorBrush(Colors.Red); | ||
| PrimaryPointerStoryboard.Begin(); | ||
| } | ||
| else | ||
| { | ||
| PrimaryPointerStoryboard.Stop(); | ||
| ellipse.Fill = new SolidColorBrush(Colors.LightSkyBlue); | ||
| ellipse.Stroke = new SolidColorBrush(Colors.DodgerBlue); | ||
| } |
Comment on lines
+63
to
+70
| private void Pointer_Wheel_Changed(object sender, PointerRoutedEventArgs e) | ||
| { | ||
| PointerPoint currentPoint = e.GetCurrentPoint(mainCanvas); | ||
| if (currentPoint.IsInContact) | ||
| { | ||
| CreateOrUpdatePropertyPopUp(currentPoint); | ||
| } | ||
| } |
| </StackPanel> | ||
| </ScrollViewer> | ||
| <TextBlock Grid.Row="1" Text="Touch or click the screen to see information about the current pointer(s)" TextWrapping="Wrap" Padding="0,12,0,0"/> | ||
| <Canvas Grid.Row="2" x:Name="mainCanvas" Height="Auto" Margin="12,10,12,12" Background="Transparent"/> |
Comment on lines
+43
to
+44
| <Button x:Name="resetButton" Content="Reset" Margin="0,12,0,0" Click="resetButton_Pressed" | ||
| AutomationProperties.AutomationId="ResetButton"/> |
| new Scenario() { Title = "Gesture Recognizer Manipulations", ClassName = typeof(GestureRecognizerManipulation).FullName }, | ||
| new Scenario() { Title = "Cursor", ClassName = typeof(InputCursor).FullName } | ||
| new Scenario() { Title = "Cursor", ClassName = typeof(InputCursor).FullName }, | ||
| new Scenario() { Title = "PointerTracking", ClassName = typeof(PointerTracking).FullName }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 5 new scenario pages to the existing Input sample, migrated from Windows-universal-samples/BasicInput and windows-topic-specific-samples (branches
uwp-pointers+uwp-pointers-animation).These scenarios are referenced by multiple pages under learn.microsoft.com/windows/apps/develop/input/.
New Scenarios
KeyboardCapabilities,MouseCapabilities,TouchCapabilitiesManipulationModewith configurable translate axis (X/Y/both), rotation, and inertia toggleDoc pages that reference these scenarios
Notable details
Background="Transparent"on Canvas to ensure hit-test works in WinUI 3Assets\Landscape.jpgto Content items (was missing, needed by GestureRecognizerManipulation scenario)Testing
All 7 scenarios verified on Windows 11 with mouse + touch input in packaged mode.