Add FocusVisuals and TouchKeyboard samples (WinUI 3 migration from UWP)#649
Open
qiutongMS wants to merge 3 commits into
Open
Add FocusVisuals and TouchKeyboard samples (WinUI 3 migration from UWP)#649qiutongMS wants to merge 3 commits into
qiutongMS wants to merge 3 commits into
Conversation
Migrated from Windows-universal-samples/Samples/XamlFocusVisuals to WinUI 3. - Two scenarios: custom focus visuals + system focus visuals on custom controls - Adapted for CPM, EnablePreviewMsixTooling, net9.0 TFM - Updated CheckBox template to use rounded corners (Fluent Design) - Temporarily uncommented nuget.org in nuget.config for local dev Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Migrated from Windows-universal-samples/Samples/TouchKeyboard to WinUI 3. - 4 scenarios: auto display, show/hide events, programmatic show/hide, emoji keyboard - InputPane.GetForCurrentView() replaced with InputPaneInterop.GetForWindow() - CoreInputView COM interop fixed for .NET 9 (manual HString + IntPtr marshaling) - Adapted for CPM, EnablePreviewMsixTooling, net9.0 TFM - Removed systemAIModels capability - Graceful fallback when CoreInputView unavailable in unpackaged mode Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds two new WinUI 3 / Windows App SDK sample apps—FocusVisuals and TouchKeyboard—by migrating existing UWP samples so the docs can link to projects that build on modern tooling.
Changes:
- Added a WinUI 3 TouchKeyboard sample with 4 scenarios demonstrating SIP show/hide behavior, events, and emoji keyboard invocation.
- Added a WinUI 3 FocusVisuals sample demonstrating custom focus visuals and applying system focus visuals to a custom control.
- Included single-project MSIX packaging artifacts and launch profiles to support packaged/unpackaged workflows.
Reviewed changes
Copilot reviewed 33 out of 52 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| Samples/TouchKeyboard/cs-winui/TouchKeyboard.sln | Adds a solution for the TouchKeyboard WinUI 3 sample. |
| Samples/TouchKeyboard/cs-winui/TouchKeyboard.csproj | Defines the TouchKeyboard WinUI 3 project (target framework, WinUI/App SDK packages, assets, MSIX capability). |
| Samples/TouchKeyboard/cs-winui/Scenario4_ShowView.xaml.cs | Implements Scenario 4 logic to show the emoji keyboard via CoreInputView interop. |
| Samples/TouchKeyboard/cs-winui/Scenario4_ShowView.xaml | Scenario 4 UI for triggering emoji keyboard on focus. |
| Samples/TouchKeyboard/cs-winui/Scenario3_ShowHideMethods.xaml.cs | Implements Scenario 3: programmatic TryShow/TryHide behavior. |
| Samples/TouchKeyboard/cs-winui/Scenario3_ShowHideMethods.xaml | Scenario 3 UI with storyboard and TextBox interaction. |
| Samples/TouchKeyboard/cs-winui/Scenario2_ShowHideEvents.xaml.cs | Implements Scenario 2: InputPane Showing/Hiding event handling. |
| Samples/TouchKeyboard/cs-winui/Scenario2_ShowHideEvents.xaml | Scenario 2 UI for observing InputPane events. |
| Samples/TouchKeyboard/cs-winui/Scenario1_Launch.xaml.cs | Scenario 1 page code-behind (launch/intro). |
| Samples/TouchKeyboard/cs-winui/Scenario1_Launch.xaml | Scenario 1 UI describing automatic touch keyboard behavior and a custom TextBox control. |
| Samples/TouchKeyboard/cs-winui/Properties/launchSettings.json | Launch profiles for packaged vs unpackaged runs. |
| Samples/TouchKeyboard/cs-winui/Package.appxmanifest | MSIX manifest for the TouchKeyboard sample. |
| Samples/TouchKeyboard/cs-winui/MainWindow.xaml.cs | App shell window logic (navigation + status InfoBar). |
| Samples/TouchKeyboard/cs-winui/MainWindow.xaml | App shell UI (title bar + NavigationView + content frame). |
| Samples/TouchKeyboard/cs-winui/CustomTextBox.cs | Custom TextBox subclass used in Scenario 1. |
| Samples/TouchKeyboard/cs-winui/App.xaml.cs | App startup logic for TouchKeyboard. |
| Samples/TouchKeyboard/cs-winui/App.xaml | App resources setup for TouchKeyboard (WinUI resources). |
| Samples/TouchKeyboard/cs-winui/app.manifest | Unpackaged app manifest settings (OS compatibility + DPI awareness). |
| Samples/FocusVisuals/cs-winui/Themes/Generic.xaml | Adds a custom control template/style for the sample’s SocialMediaCounter control. |
| Samples/FocusVisuals/cs-winui/SocialMediaCounter.cs | Implements the custom HyperlinkButton-derived control used to demonstrate system focus visuals. |
| Samples/FocusVisuals/cs-winui/Scenarios/CustomFocusVisualsPage.xaml.cs | Code-behind for the “custom focus visuals” scenario page. |
| Samples/FocusVisuals/cs-winui/Scenarios/CustomFocusVisualsPage.xaml | Scenario page demonstrating a custom CheckBox focus visual template. |
| Samples/FocusVisuals/cs-winui/Scenarios/CustomControlUsagePage.xaml.cs | Code-behind for the “custom control usage” scenario page. |
| Samples/FocusVisuals/cs-winui/Scenarios/CustomControlUsagePage.xaml | Scenario page applying system focus visuals to a custom control instance. |
| Samples/FocusVisuals/cs-winui/Properties/launchSettings.json | Launch profiles for packaged vs unpackaged runs. |
| Samples/FocusVisuals/cs-winui/Package.appxmanifest | MSIX manifest for the FocusVisuals sample. |
| Samples/FocusVisuals/cs-winui/MainWindow.xaml.cs | App shell window logic (navigation). |
| Samples/FocusVisuals/cs-winui/MainWindow.xaml | App shell UI (title bar + NavigationView + frame). |
| Samples/FocusVisuals/cs-winui/FocusVisualsSample.sln | Adds a solution for the FocusVisuals WinUI 3 sample. |
| Samples/FocusVisuals/cs-winui/FocusVisualsSample.csproj | Defines the FocusVisuals WinUI 3 project (WinUI/App SDK packages, assets, MSIX capability). |
| Samples/FocusVisuals/cs-winui/App.xaml.cs | App startup logic for FocusVisuals. |
| Samples/FocusVisuals/cs-winui/App.xaml | App resources setup for FocusVisuals (includes Generic.xaml). |
| Samples/FocusVisuals/cs-winui/app.manifest | Unpackaged app manifest settings (OS compatibility + DPI awareness). |
- Add copyright/MIT license headers to all C# and XAML files - Add ARM64 build/deploy configurations to both .sln files - Fix WindowsCreateString: use string.Length instead of hardcoded 51 - Add base.OnNavigatedTo/OnNavigatedFrom calls in Scenario2 and Scenario3 - Fix KeyDown/KeyUp event mismatch in Scenario3 XAML (KeyDown -> KeyUp) - Rename generic 'Button' labels to 'Dismiss keyboard' for clarity - Add AutomationProperties.Name to SocialMediaCounter custom control Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines
+32
to
+35
| var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(window); | ||
| _inputPane = InputPaneInterop.GetForWindow(hwnd); | ||
|
|
||
| _inputPane.Showing += OnShowing; |
Comment on lines
+33
to
+35
| var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(window); | ||
| _inputPane = InputPaneInterop.GetForWindow(hwnd); | ||
| } |
Comment on lines
+27
to
+30
| var window = MainWindow.Current; | ||
| if (window is null) return; | ||
|
|
||
| var hwnd = WindowNative.GetWindowHandle(window); |
Comment on lines
+20
to
+23
| <Image Height="30" Control.IsTemplateFocusTarget="True" Source="{Binding ShareImage, RelativeSource={RelativeSource TemplatedParent}}" /> | ||
|
|
||
| <Path Data="M0.5,0.5 L155.5,0.5 L155.5,155.5 L0.5,155.5 L0.5,100 L-37.3739,77.3333 L0.416768,50 z" Stretch="Fill" Stroke="{ThemeResource SystemControlForegroundBaseHighBrush}" Height="20" Width="30" HorizontalAlignment="Left" UseLayoutRounding="False" Grid.Column="1"/> | ||
| <TextBlock Text="{Binding NumOfShares, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource CaptionTextBlockStyle}" Margin="11,6,0,0" Grid.Column="1" /> |
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
Migrates two UWP samples to WinUI 3 / Windows App SDK:
These samples are referenced by 12+ pages under learn.microsoft.com/windows/apps/develop/input/. The existing UWP sample links point to archived repos that no longer build on modern tooling.
FocusVisuals Sample
Demonstrates custom focus visual styling in WinUI 3:
Templatefocus visual kind and rounded corners (WinUI 3 Fluent style)TouchKeyboard Sample
Demonstrates software keyboard (SIP) interactions in WinUI 3:
InputPane.Showing/Hidingto adjust layoutInputPane.TryShow()/TryHide()CoreInputView(requires package identity)Notable technical details
MarshalAs(UnmanagedType.HString)no longer works — replaced with manualWindowsCreateString/WindowsDeleteString+IntPtrmarshalingWindowsAppSDKSelfContained=true)Testing
All scenarios verified on Windows 11 with mouse + touch input, in both packaged and unpackaged deployment modes.