From 9ba5f7368a852a94f57cea273ac086464b17c473 Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Sat, 21 Oct 2023 22:02:55 +0200 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 220426eaae00523472b0fd4f2a25c17cb232522d Author: Marcel Wagner Date: Tue Oct 17 20:40:21 2023 +0200 Fix sample presenter not properly determing if its empty (#1374) The sample presenter did not properly determine if it was empty resulting in it not hiding despite it being empty. Fixes #1373 - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) commit b78b8a52cbd5463e27b5474330f4f1b4b0b5e3c5 Author: Marcel Wagner Date: Tue Oct 17 20:35:26 2023 +0200 Fix Selection Indicator for GridView sample (#1385) Due to a missing BasedOn, the selection indicator and other interface characteristics where missing on the custom layout sample. Fixes #1072 - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) commit 09424a9014c490d3d09300a02fadc5874bd2e552 Author: Karen <7976322+karkarl@users.noreply.github.com> Date: Mon Oct 16 17:41:14 2023 -0700 Refactor IconsPage ItemsRepeater to ItemsView (#1376) The ItemsRepeater for IconsPage has too many accessibility issues including lack of keyboard navigation and narrator announcement. Refactored to ItemsView that has all of it built in. Also added Narrator announcement when filtered items have changed. [Bug 44661633](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/44661633): [WinUI Accessibility: Design guidance -> Icons]: Unable to navigate and access the Icons present under “Fluent Icons Library” using keyboard. [Bug 44661471](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/44661471): [WinUI Accessibility: Design guidance -> Icons]: Screen reader fails to announce regarding the available suggestions. Manual verification - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) commit 85d39457ed482a9a24b0bea0dd8f9ec530b03827 Author: Marcel Wagner Date: Tue Oct 17 01:26:29 2023 +0200 Update infobadge samples to be more accessible (#1311) Fixes #769 - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) commit a735e5096553e0f84d2596a024334cfad7d38866 Author: Marcel Wagner Date: Tue Oct 17 00:55:19 2023 +0200 Rename NewControls page to Homepage (#1381) Renames the NewControls page to HomePage since the menu item is called "Home" and showing new control samples is no longer its only purpose. Part of #1279 - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) commit cd00c137bef96592f16829adb695d70a964017cf Author: Marcel Wagner Date: Tue Oct 17 00:53:49 2023 +0200 Update ListView sample code to match used resources (#1383) The brushes used for the messaging sample were out of date which this PR addresses. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) commit afd79ceb9eda12f1aa8f7797b32138c566f38181 Author: Ranjesh <28935693+ranjeshj@users.noreply.github.com> Date: Mon Oct 16 09:24:53 2023 -0700 Add ToString method to view model in StandardUICommand sample so accessibility name does not default to data type name. (#1382) Without a ToString, accessibility tools end up using the TypeName. ![image](https://github.com/microsoft/WinUI-Gallery/assets/28935693/6604dc35-626d-484d-b300-4c366acdb6fd) After fix: ![image](https://github.com/microsoft/WinUI-Gallery/assets/28935693/d809ffdd-7532-4177-a5a5-06a81fa21ac5) commit b1572ee7c87b1a2c361215b9ac8c4cd96dc56ce8 Author: Karen <7976322+karkarl@users.noreply.github.com> Date: Wed Oct 11 13:51:39 2023 -0700 P1 Accessibility Fixes (#1380) Miscellaneous p1 accessibility fixes: - [Bug 44661786](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/44661786): [WinUI Accessibility: Design guidance -> Accessibility-> Keyboard support]: Screen reader is announcing incorrect information about the shortcuts. - [Bug 46762667](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/46762667): [WinUI 3 Gallery: Item View]: Screen reader fails to announce the label for the radio buttons present in under 'Layout' group. - [Bug 46763238](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/46763238): [WinUI 3 Gallery: Progress Ring]: Accessibility name and visual name is not same for working toggle button present under 'Toggle Work' group. - [Bug 46818786](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/46818786): [WinUI 3 Gallery: Clipboard]: Screen reader is not announcing the success message after activating the 'Copy Text to the Clipboard' button. - [Bug 46818852](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/46818852): [WinUI 3 Gallery: FilePicker]: Screen reader is not announcing the success message after activating the 'Open a file/Open a picture/Save a file' button. - [Bug 46820249](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/46820249): [WinUI 3 Gallery: Design Guidance: Color]: Upon invoking 'Copy brush name' button screen reader is on mute and there is no visual changes. - [Bug 46820807](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/46820807): [WinUI 3 Gallery: Typography]: Some parts of right side of the screen is getting truncated in High DPI mode also not having scroll bar to scroll towards right. - [Bug 46821911](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/46821911): [WinUI 3 Gallery: List View]: Text present beside the images which present under 'List view with image' heading is getting truncated in normal mode. - [Bug 46825231](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/46825231): [WinUI 3 Gallery: Connected Animation]: Text present beside the images which present in 'Connected Animation' card is getting truncated in normal mode. - [Bug 41570653](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/41570653): [WinUI Accessibility-> Left Navigation Pane]: No success information announced by screen reader, when user invokes open/close navigation button. - [Bug 41597549](https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/41597549): [WinUI Gallery] WinUI Accessibility-> TeachingTip: Unable to navigate to the image present in "Quickly reference this sample!" dialog using caps arrow keys. - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) commit 9a2c60b4a5f6fa39bb0d63cabb42976f9511dd27 Author: Karen <7976322+karkarl@users.noreply.github.com> Date: Wed Oct 11 12:32:02 2023 -0700 Add Test to Scan All Pages for Axe Issues (#1361) - Add a test that physically navigates to each page via NavView and check for Axe issues. - Utilizes DynamicData attribute to create grouped tests based on section category (ie. TreeView parent) - This also tests for run-time crashes with each page. - Miscellaneous Axe fixes. - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) commit 1d237241853b788e3f551a5a2de6f47fc5693a2f Author: Marcel Wagner Date: Wed Oct 11 02:31:01 2023 +0200 Cleanup unnecessary code (#1299) commit 20cd4578ea899f5b42e44daa0fdc51d1a1696158 Author: Scott Jones Date: Tue Oct 10 17:30:05 2023 -0700 Update to WinAppSDK 1.4.2 and remove temporary workaround for including version info without dupe warnings (#1379) commit c2fd30d7841299af4b0cc68748123abd4af11cb2 Author: Scott Jones Date: Tue Oct 10 10:47:39 2023 -0700 Set TrimMode explicitly back to partial for .NET 7 compat (#1378) See: https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-7-0 commit f72609f238dab5d2ad499ddf15a86542d4f4d330 Author: Pratik Anand Date: Tue Oct 3 12:29:10 2023 -0700 Clickable Interactive control sample for custom titlebar (#1360) With 1.4 changes, WinUI 3 custom titlebar now uses appwindow titlebar + nonclientinputpointersource apis under the hood. This opens up new possibilities like allowing clickable interactive controls like textbox, button in the titlebar area, surrounded by draggable region on both left and the right sides. This code adds a sample to titlebar page which shows users how to create interactive controls in winui 3 titlebar. It also demonstrates the power of mixing and matching high level winui 3 custom titlebar apis and low level nonclient apis. commit 5a96afc71bfb633be0200d38c2a2ee14750ef2c8 Author: Andrew KeepCoding Date: Thu Sep 28 19:31:59 2023 +0900 Fix issue that crashes the app when navigating to SemanticZoomPage (#1363) commit 9650e4eed1eb7beda53b20be2d53f8d5098ab02a Author: Marcel Wagner Date: Thu Sep 28 12:31:39 2023 +0200 Switch .NET 7 (#1115) commit 8f1b4259f79f8a01669fcc5eac9c7007387495fa Author: Marcel Wagner Date: Thu Sep 28 12:31:22 2023 +0200 First round of UWP link replacement (#1347) Co-authored-by: Bob Pulliam commit 1fcd8edcfc6cc942a175d519c55a4cfd2f96a4f0 Author: Steve Date: Thu Sep 28 05:21:29 2023 +0900 Fix division by zero (#1366) Fix division by zero exception when the window is too narrow. Fixes #1365 - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) commit cbfc1fbee1aa4450e3e1fc5294f1d2a6717570b4 Author: Scott Jones Date: Sun Sep 24 04:55:17 2023 -0700 Fixes for WinUI submodule compatibility (#1362) commit 398af50b49909bcc3ef180bb81006ffa7bc406ac Author: Scott Jones Date: Wed Sep 20 04:03:02 2023 -0700 Update to WinAppSDK 1.4.1 and remove menu theme workaround (#1359) commit 9c80909c39abb195cd0ab4f1bfcb690c98afa4ea Author: Mike Crider <45052236+codendone@users.noreply.github.com> Date: Mon Sep 18 21:42:15 2023 -0700 Added a "Capture element / camera preview" page in the Media section. (#1357) `CaptureElement` from UWP XAML does not exist in WinAppSDK, but `MediaPlayerElement` can be used in its place. The change adds a new sample page to demonstrate how this can be done. Note: Currently this page just reuses the same icon as the MediaPlayerElement page. Ideally at some point we'll get a camera icon which could be used here instead. Demonstrate the couple of calls to get from a `MediaCapture` to an `IMediaPlaybackSource` necessary to display the capture in a MediaPlayerElement. This also demonstrates basic creation of a `MediaCapture` to provide an end-to-end sample. This sample should help address questions in microsoft/microsoft-ui-xaml#4710 and microsoft/microsoft-ui-xaml#8214. Ad-hoc testing and testing with Accessibility Insights for Windows tool. - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) commit 258d8c8b033b456689675b5f76cf66f62d5c300a Merge: 46137e8 6d4d692 Author: Karen <7976322+karkarl@users.noreply.github.com> Date: Mon Sep 18 14:14:37 2023 -0700 Merge pull request #1354 from ghost1372/AcrylicKind Add new Desktop Acrylic kind (Base and Thin) commit 6d4d692084c8254107a48bb0ab518be5ecc7aca9 Author: Mahdi Hosseini Date: Tue Sep 19 00:17:19 2023 +0330 fix indent commit 41df384ffad6f1b76156c5ae63bd1a03c2e133be Author: Mahdi Hosseini Date: Sat Sep 9 14:11:01 2023 +0330 Add Missing Sample for Desktop Acrylic commit 05d2c8077ef4d8f5c1beebc7f817bdeae43a4c58 Author: Mahdi Hosseini Date: Sat Sep 9 14:03:42 2023 +0330 Update SystemBackdropsSample commit 97afe684e3ad8be471af4eef8d4a73d6c79339ee Author: Mahdi Hosseini Date: Sat Sep 9 14:03:14 2023 +0330 Add DesktopAcrylic Kind (Base, Thin) commit 46137e8d182d6eea1af95bae643507fde2577186 Author: Karen <7976322+karkarl@users.noreply.github.com> Date: Fri Sep 8 17:15:16 2023 -0700 WinUI Gallery 2.2.0.0 Release (#1353) commit eb7171181e0c358736ea00e829c8a99dcf34b0f8 Merge: 10d21fb 6f42854 Author: Scott Jones Date: Fri Sep 8 11:22:05 2023 -0700 Merge pull request #1352 from microsoft/scottj1s/disable_r2r disable ReadyToRun as it was mistakenly trimming Microsoft.UI.Xaml.Controls.ScrollView from Microsoft.WinUI.dll commit 6f42854c9c75da10aa507de600f2e5d2ef349faa Author: Scott Jones Date: Fri Sep 8 11:05:21 2023 -0700 disable ReadyToRun as it was mistakenly trimming Microsoft.UI.Xaml.Controls.ScrollView from Microsoft.WinUI.dll --- UITests/AxeHelper.cs | 3 +- UITests/Tests/AxeScanAllTests.cs | 116 ++++++ UITests/Tests/Button.cs | 6 - UITests/Tests/CheckBox.cs | 6 - UITests/Tests/ComboBox.cs | 8 - UITests/Tests/DatePicker.cs | 6 - UITests/Tests/MediaPlayerElement.cs | 6 - UITests/Tests/PersonPicture.cs | 6 - UITests/Tests/ProgressBar.cs | 6 - UITests/Tests/RadioButton.cs | 6 - UITests/Tests/Slider.cs | 6 - UITests/Tests/TextBlock.cs | 6 - UITests/Tests/TextBox.cs | 6 - UITests/Tests/ToggleButton.cs | 6 - UITests/Tests/ToggleSwitch.cs | 6 - UITests/UITests.csproj | 11 + WinUIGallery/App.xaml.cs | 9 +- .../Assets/ControlImages/Placeholder.png | Bin 0 -> 5368 bytes WinUIGallery/Common/ActivityFeedLayout.cs | 6 +- WinUIGallery/Common/Category.cs | 3 +- .../Common/ColorSlideTransitionHelper.cs | 7 +- .../Common/MenuItemTemplateSelector.cs | 4 +- WinUIGallery/Common/Win32.cs | 1 - WinUIGallery/Common/WrapPanel.cs | 4 +- .../CollectionPage.xaml | 9 +- .../CollectionPage.xaml.cs | 12 +- WinUIGallery/ContentIncludes.props | 7 +- .../AnnotatedScrollBarPage.xaml.cs | 3 +- .../ControlPages/AppBarSeparatorPage.xaml.cs | 11 - .../AppBarToggleButtonPage.xaml.cs | 11 - .../CaptureElementPreviewPage.xaml | 31 ++ .../CaptureElementPreviewPage.xaml.cs | 130 ++++++ .../ControlPages/ClipboardPage.xaml.cs | 5 + .../ControlPages/ComboBoxPage.xaml.cs | 2 +- .../ControlPages/CommandBarPage.xaml.cs | 1 - .../CreateMultipleWindowsPage.xaml.cs | 9 +- .../AccessibilityKeyboardPage.xaml | 3 + .../DesignGuidance/IconsPage.xaml | 66 ++- .../DesignGuidance/IconsPage.xaml.cs | 48 +-- .../DesignGuidance/TypographyPage.xaml | 366 +++++++++-------- .../ControlPages/FilePickerPage.xaml.cs | 13 +- WinUIGallery/ControlPages/GridViewPage.xaml | 4 +- WinUIGallery/ControlPages/InfoBadgePage.xaml | 22 +- .../ControlPages/ItemsRepeaterPage.xaml | 1 - .../ControlPages/ItemsRepeaterPage.xaml.cs | 30 -- WinUIGallery/ControlPages/ItemsViewPage.xaml | 11 +- WinUIGallery/ControlPages/ListViewPage.xaml | 9 +- .../ControlPages/ListViewPage.xaml.cs | 12 + WinUIGallery/ControlPages/MenuBarPage.xaml | 6 +- WinUIGallery/ControlPages/MenuBarPage.xaml.cs | 14 +- WinUIGallery/ControlPages/MenuFlyoutPage.xaml | 12 +- .../ControlPages/MenuFlyoutPage.xaml.cs | 15 +- .../ControlPages/NavigationViewPage.xaml.cs | 31 -- .../ControlPages/ProgressRingPage.xaml | 2 +- .../ControlPages/PullToRefreshPage.xaml.cs | 3 +- .../ControlPages/RichEditBoxPage.xaml.cs | 16 +- .../ControlPages/RichTextBlockPage.xaml | 6 +- .../ControlPages/ScrollViewerPage.xaml.cs | 28 +- .../ControlPages/SplitViewPage.xaml.cs | 22 - .../ControlPages/StandardUICommandPage.xaml | 2 +- .../StandardUICommandPage.xaml.cs | 13 +- .../ControlPages/SystemBackdropsPage.xaml | 5 + .../ControlPages/SystemBackdropsPage.xaml.cs | 9 +- WinUIGallery/ControlPages/TitleBarPage.xaml | 53 ++- .../ControlPages/TitleBarPage.xaml.cs | 94 ++++- .../ItemsRepeaterSample3_xaml.txt | 1 - .../Media/CaptureElementPreviewSample_cs.txt | 48 +++ .../CaptureElementPreviewSample_xaml.txt | 10 + .../ConnectedAnimationSample1_cs.txt | 3 +- .../SystemBackdropsSample1.txt | 4 +- .../SystemBackdropsSample2.txt | 4 +- .../RichEditBox/RichEditBoxSample3_cs.txt | 2 +- .../Window/CreateWindowSample1.txt | 2 +- .../Window/TitleBar/TitleBarSample2.txt | 4 +- .../Window/TitleBar/TitleBarSample3.txt | 22 + WinUIGallery/Controls/ControlExample.xaml | 2 +- .../Controls/DesignGuidance/ColorTile.xaml.cs | 2 + WinUIGallery/Controls/HeaderTile.xaml.cs | 31 -- WinUIGallery/Controls/PageHeader.xaml | 2 +- .../Controls/SampleCodePresenter.xaml.cs | 9 +- WinUIGallery/DataModel/ControlInfoData.json | 55 ++- WinUIGallery/Directory.Build.props | 2 + WinUIGallery/Directory.Build.targets | 4 +- WinUIGallery/Helper/NavigationHelper.cs | 80 ---- WinUIGallery/Helper/ThemeHelper.cs | 3 - WinUIGallery/Helper/TitleBarHelper.cs | 25 +- WinUIGallery/Helper/WindowHelper.cs | 15 + .../{NewControlsPage.xaml => HomePage.xaml} | 2 +- ...wControlsPage.xaml.cs => HomePage.xaml.cs} | 4 +- WinUIGallery/IdleSynchronizer.cs | 118 +----- WinUIGallery/ItemsPageBase.cs | 1 - .../Navigation/NavigationRootPage.xaml | 11 +- .../Navigation/NavigationRootPage.xaml.cs | 24 +- WinUIGallery/Package.Dev.appxmanifest | 2 +- WinUIGallery/Package.appxmanifest | 2 +- WinUIGallery/Properties/AssemblyInfo.cs | 4 +- .../win10-arm64-unpackaged.pubxml | 10 +- .../PublishProfiles/win10-arm64.pubxml | 10 +- .../win10-x64-unpackaged.pubxml | 10 +- .../PublishProfiles/win10-x64.pubxml | 10 +- .../win10-x86-unpackaged.pubxml | 10 +- .../PublishProfiles/win10-x86.pubxml | 10 +- .../SampleSystemBackdropsWindow.xaml.cs | 38 +- WinUIGallery/Strings/en-US/Resources.resw | 4 +- .../TabViewWindowingSamplePage.xaml.cs | 383 ++++++++---------- WinUIGallery/WinUIGallery.csproj | 18 +- ...override.targets => net7.override.targets} | 0 WinUIGallery/standalone.props | 4 +- nuget.config | 2 +- 109 files changed, 1262 insertions(+), 1136 deletions(-) create mode 100644 UITests/Tests/AxeScanAllTests.cs create mode 100644 WinUIGallery/Assets/ControlImages/Placeholder.png create mode 100644 WinUIGallery/ControlPages/CaptureElementPreviewPage.xaml create mode 100644 WinUIGallery/ControlPages/CaptureElementPreviewPage.xaml.cs create mode 100644 WinUIGallery/ControlPagesSampleCode/Media/CaptureElementPreviewSample_cs.txt create mode 100644 WinUIGallery/ControlPagesSampleCode/Media/CaptureElementPreviewSample_xaml.txt create mode 100644 WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample3.txt rename WinUIGallery/{NewControlsPage.xaml => HomePage.xaml} (99%) rename WinUIGallery/{NewControlsPage.xaml.cs => HomePage.xaml.cs} (96%) rename WinUIGallery/{net6.override.targets => net7.override.targets} (100%) diff --git a/UITests/AxeHelper.cs b/UITests/AxeHelper.cs index 089c4c094..2397bb39f 100644 --- a/UITests/AxeHelper.cs +++ b/UITests/AxeHelper.cs @@ -45,7 +45,8 @@ public static void AssertNoAccessibilityErrors() .Where(rule => rule.Rule.ID != RuleId.SiblingUniqueAndFocusable); if (testResult.Any()) { - var mappedResult = testResult.Select(result => "Element " + result.Element.Properties["ControlType"] + " violated rule '" + result.Rule.Description + "'."); + var mappedResult = testResult.Select(result => + "Element " + result.Element.Properties["ControlType"] + " violated rule '" + result.Rule.Description + "'."); Assert.Fail("Failed with the following accessibility errors \r\n" + string.Join("\r\n", mappedResult)); } } diff --git a/UITests/Tests/AxeScanAllTests.cs b/UITests/Tests/AxeScanAllTests.cs new file mode 100644 index 000000000..e642f6913 --- /dev/null +++ b/UITests/Tests/AxeScanAllTests.cs @@ -0,0 +1,116 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestPlatform; +using OpenQA.Selenium.Appium.Windows; +using System; +using System.Linq; +using System.Text.Json; +using System.IO; +using System.Collections.ObjectModel; +using System.Collections; +using System.Collections.Generic; +using System.Xml; +using System.Reflection; +using Newtonsoft.Json; + +namespace UITests.Tests +{ + [TestClass] + public class AxeScanAll : TestBase + { + public static readonly string jsonUri = "ControlInfoData.json"; + public static new WindowsDriver Session => SessionManager.Session; + + public static string[] ExclusionList = + { + "WebView2", // 46668961: Web contents from WebView2 are throwing null BoundingRectangle errors. + "Icons" // https://github.com/CommunityToolkit/Windows/issues/240 External toolkit SettingsExpander does not pass Axe testing + }; + + public class ControlInfoData + { + public List Groups { get; set; } + } + + public class Group + { + [JsonProperty("UniqueId")] + public string UniqueId { get; set; } + + [JsonProperty("Items")] + public List Items { get; set; } + } + + public class Item + { + [JsonProperty("UniqueId")] + public string UniqueId { get; set; } + } + + private static IEnumerable TestData() + { + var testCases = new List(); + + string jsonContent = System.IO.File.ReadAllText(jsonUri); + var controlInfoData = JsonConvert.DeserializeObject(jsonContent); + + foreach (var group in controlInfoData.Groups) + { + var sectionName = group.UniqueId; + + // Select all row names within the current table + var items = group.Items; + + foreach (var item in items) + { + var pageName = item.UniqueId; + + // Skip pages in the exclusion list. + if (ExclusionList.Contains(pageName)) + { + continue; + } + testCases.Add(new object[] { sectionName, pageName }); + } + } + + return testCases; + } + + [ClassInitialize] + public static void ClassInitialize(TestContext context) + { + } + + [TestMethod] + [DynamicData(nameof(TestData), DynamicDataSourceType.Method, DynamicDataDisplayName = nameof(GetCustomDynamicDataDisplayName))] + [TestProperty("Description", "Scan pages in the WinUIGallery for accessibility issues.")] + public void ValidatePageAccessibilityWithAxe(string sectionName, string pageName) + { + try + { + // Click into page and check for accessibility issues. + var page = Session.FindElementByAccessibilityId(pageName); + page.Click(); + + AxeHelper.AssertNoAccessibilityErrors(); + } + catch + { + // If element is not found, expand tree view as it is nested. + var section = Session.FindElementByAccessibilityId(sectionName); + section.Click(); + + // Click into page and check for accessibility issues. + var page = Session.FindElementByAccessibilityId(pageName); + page.Click(); + + AxeHelper.AssertNoAccessibilityErrors(); + } + } + + public static string GetCustomDynamicDataDisplayName(MethodInfo methodInfo, object[] data) + { + return string.Format("Validate{0}PageAccessibility", data[1]); + } + } +} diff --git a/UITests/Tests/Button.cs b/UITests/Tests/Button.cs index 1baa850db..09c0993b5 100644 --- a/UITests/Tests/Button.cs +++ b/UITests/Tests/Button.cs @@ -32,12 +32,6 @@ public static void ClassInitialize(TestContext context) Assert.IsNotNull(buttonElement); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void Button_Click() { diff --git a/UITests/Tests/CheckBox.cs b/UITests/Tests/CheckBox.cs index ad626d57b..06630d9d0 100644 --- a/UITests/Tests/CheckBox.cs +++ b/UITests/Tests/CheckBox.cs @@ -34,12 +34,6 @@ public static void ClassInitialize(TestContext context) Assert.IsNotNull(checkBoxElement2); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void Click() { diff --git a/UITests/Tests/ComboBox.cs b/UITests/Tests/ComboBox.cs index 3921663b1..0497730b2 100644 --- a/UITests/Tests/ComboBox.cs +++ b/UITests/Tests/ComboBox.cs @@ -36,17 +36,9 @@ public static void ClassInitialize(TestContext context) Assert.IsNotNull(comboBoxElement2); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void Click() { - - // Click comboBoxElement1 to show the list and simply dismiss it var originalSelectedItem = comboBoxElement1.Text; comboBoxElement1.Click(); diff --git a/UITests/Tests/DatePicker.cs b/UITests/Tests/DatePicker.cs index 11cf6abe6..2f9fce9d2 100644 --- a/UITests/Tests/DatePicker.cs +++ b/UITests/Tests/DatePicker.cs @@ -37,12 +37,6 @@ public static void ClassInitialize(TestContext context) Assert.IsNotNull(datePickerElement2); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void Click() { diff --git a/UITests/Tests/MediaPlayerElement.cs b/UITests/Tests/MediaPlayerElement.cs index 24d6a4b16..a6203814f 100644 --- a/UITests/Tests/MediaPlayerElement.cs +++ b/UITests/Tests/MediaPlayerElement.cs @@ -35,12 +35,6 @@ public static void ClassInitialize(TestContext context) GetElementByName("MediaPlayerElement").Click(); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void PlayMedia() { diff --git a/UITests/Tests/PersonPicture.cs b/UITests/Tests/PersonPicture.cs index 22596fd33..83e91390f 100644 --- a/UITests/Tests/PersonPicture.cs +++ b/UITests/Tests/PersonPicture.cs @@ -28,12 +28,6 @@ public static void ClassInitialize(TestContext context) OpenControlPage("PersonPicture"); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void SwitchOptions() { diff --git a/UITests/Tests/ProgressBar.cs b/UITests/Tests/ProgressBar.cs index 25a01df2d..fc0194aa7 100644 --- a/UITests/Tests/ProgressBar.cs +++ b/UITests/Tests/ProgressBar.cs @@ -37,12 +37,6 @@ public static void ClassInitialize(TestContext context) Assert.IsNotNull(clickAndHoldButton); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void Displayed() { diff --git a/UITests/Tests/RadioButton.cs b/UITests/Tests/RadioButton.cs index 8f16ae2c7..cc28a8515 100644 --- a/UITests/Tests/RadioButton.cs +++ b/UITests/Tests/RadioButton.cs @@ -36,12 +36,6 @@ public static void ClassInitialize(TestContext context) Assert.IsNotNull(radioButtonElement2); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void Click() { diff --git a/UITests/Tests/Slider.cs b/UITests/Tests/Slider.cs index 61df44aa4..6579ff7f3 100644 --- a/UITests/Tests/Slider.cs +++ b/UITests/Tests/Slider.cs @@ -36,12 +36,6 @@ public static void ClassInitialize(TestContext context) Assert.IsNotNull(sliderElement2); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void Click() { diff --git a/UITests/Tests/TextBlock.cs b/UITests/Tests/TextBlock.cs index b597e7af5..f9f35cc8a 100644 --- a/UITests/Tests/TextBlock.cs +++ b/UITests/Tests/TextBlock.cs @@ -37,12 +37,6 @@ public static void ClassInitialize(TestContext context) Assert.IsNotNull(textBlockElement2); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void Displayed() { diff --git a/UITests/Tests/TextBox.cs b/UITests/Tests/TextBox.cs index 863e572e0..6be2550f6 100644 --- a/UITests/Tests/TextBox.cs +++ b/UITests/Tests/TextBox.cs @@ -38,12 +38,6 @@ public static void ClassInitialize(TestContext context) Assert.IsNotNull(textBoxElement2); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void Clear() { diff --git a/UITests/Tests/ToggleButton.cs b/UITests/Tests/ToggleButton.cs index 62ed86a66..588544873 100644 --- a/UITests/Tests/ToggleButton.cs +++ b/UITests/Tests/ToggleButton.cs @@ -33,12 +33,6 @@ public static void ClassInitialize(TestContext context) Assert.IsNotNull(toggleButtonElement); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void Click() { diff --git a/UITests/Tests/ToggleSwitch.cs b/UITests/Tests/ToggleSwitch.cs index da5445c09..db22e3b1c 100644 --- a/UITests/Tests/ToggleSwitch.cs +++ b/UITests/Tests/ToggleSwitch.cs @@ -33,12 +33,6 @@ public static void ClassInitialize(TestContext context) Assert.IsNotNull(toggleSwitchElement); } - [TestMethod] - public void ValidateAccessibilityWithAxe() - { - AxeHelper.AssertNoAccessibilityErrors(); - } - [TestMethod] public void Click() { diff --git a/UITests/UITests.csproj b/UITests/UITests.csproj index 9994eb5a2..7c6e325d3 100644 --- a/UITests/UITests.csproj +++ b/UITests/UITests.csproj @@ -8,6 +8,13 @@ win10-x86;win10-x64;win10-arm64 + + + $(MSBuildThisFileDirectory)..\ + $(MSBuildThisFileDirectory)\bin\ + \$(Platform)\$(Configuration)\$(TargetFramework) + + @@ -15,4 +22,8 @@ + + + + \ No newline at end of file diff --git a/WinUIGallery/App.xaml.cs b/WinUIGallery/App.xaml.cs index 81fd71318..854573932 100644 --- a/WinUIGallery/App.xaml.cs +++ b/WinUIGallery/App.xaml.cs @@ -113,11 +113,6 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar startupWindow = WindowHelper.CreateWindow(); startupWindow.ExtendsContentIntoTitleBar = true; #if DEBUG - //if (System.Diagnostics.Debugger.IsAttached) - //{ - // this.DebugSettings.EnableFrameRateCounter = true; - //} - if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.BindingFailed += DebugSettings_BindingFailed; @@ -150,7 +145,7 @@ private async void EnsureWindow(IActivatedEventArgs args = null) ThemeHelper.Initialize(); - Type targetPageType = typeof(NewControlsPage); + Type targetPageType = typeof(HomePage); string targetPageArguments = string.Empty; if (args != null) @@ -203,7 +198,7 @@ private async void EnsureWindow(IActivatedEventArgs args = null) NavigationRootPage rootPage = StartupWindow.Content as NavigationRootPage; rootPage.Navigate(targetPageType, targetPageArguments); - if (targetPageType == typeof(NewControlsPage)) + if (targetPageType == typeof(HomePage)) { ((Microsoft.UI.Xaml.Controls.NavigationViewItem)((NavigationRootPage)App.StartupWindow.Content).NavigationView.MenuItems[0]).IsSelected = true; } diff --git a/WinUIGallery/Assets/ControlImages/Placeholder.png b/WinUIGallery/Assets/ControlImages/Placeholder.png new file mode 100644 index 0000000000000000000000000000000000000000..16894dac6297ac130a947599873bbac386d846ba GIT binary patch literal 5368 zcmV1~0u%=Wc6J>oaUUxerAcXO zLZiB>y&H@`EEs`;*9K#d&Dz0_7{?|ePAsru2_qtu-SzIb`|bCfn{)2-+?iS1>wPB5 zwZ^mG%$+;;{^mS>=iEEP*ze2lOyRI4?!5EPB){_eN`xfP_a`tr*!BY1*MahVRlalK^$wDwFUyNc^x1p$Cpt+7(E%7zMs&Q0Im za3375z*c2bT#{^Riv;c3Yp=~dy5WiTY%aGdk>HGTvw;}G??f^I`{c5l|Ku+l&zwHF zYjALI%B60~Bo0)OV?of?tbJ^2DwDaJCtPTJ$tqc z)oN^t%2Y`lKY8+G0=C?v|MEn8CY!w*fr@*K+~_S=l9vR@Te$ef#*fdO+BGmRfM=$} zVN3;Z9K0t#e*AcL_1b>|o0gF_%>op6fmU1GClU$RCzdVzqZ=E}oc{Uipth*8ldiUt zs;XK&(R*gU^HCJyC2kc(jCTR5=#jh*tE>I zp8WpS6o6*^>G`j+py@_f5>z&uO|kmAx>a|6`N4K*Gpz~pq?Jj#8Is%6r%z|Uw)U}( z^aa!tVZt*MF!MK8XO!9|mD)BfTHf$R*DFSCC&lJXhN?=ry87y?a}TwAvmHQNITC0J z8w(o&&>VLqfP(?5ZB4M^aG4E(w|)A_f4v`0l>p@0`E2HRl!;bV=?Gw-UDNXTRs@am zG*b{53JyXhe+yxc3sTQOh|-sY_OiJ&tDjM~a^0gF+u;Faq3sFRqzSzN+MUgtH_M11 zo6UOaX#i2bLr#&ZDAQ^o+z~362wnmo1QO*$3aHBR#v=#c*+nj&kTOxg;aHQvvob0o z$gT=YS-8Zhqq1wpgp+u z(e`vi(tK%Rv4FYro;(U#)5@Y#T`hS?l5hONpEqo4-#lTGH{KT1I)XJ{2XdRut#m>b zGWd*zh9jtkhU80u$?0)t=i9Ty;Dh#&|jh4w9Cb zKYxB^&AP|8LY8Btf7;n5VZDKH|MYLS*~{b>p(o~Q3!3bLl)6+Z!7|x2n|axcm1|nt zI^aYaj;D}-v+)`%8=oTcX-IBYKaA>`ky#E}1l2bdRzDF@NwxC<3@JHjTgkDCGNO_< zG&t1xO6QjQKmGL65>q^H%&I#cHcnCwNp2r`Y-=Wm0lUd=Fx5xmIR#O%IQwRRv_Hct z%DC4Kl|s^l^0r8Q5}1-oEW3We^2Sfkp2oz0VABLR84;|0_!}r`cl$O?l{hC5GH=YM zy^M))1#&E6syMCb5k0vj0lZ`~x$L^8rH$_$?%t&v98-ib78_^M-8luC$=sSzkOvzT zDtAfj8Wt>V+`Ff1 z*Wts51@Js}NrPvjFOuBCmTh^gtpgo_$(Q+(p$#^Rvq4n#s6+`CF9bYd%Y*?(_;>X0 z6KTe#;TxKkHSFE9W7kbL-6YPOIWuat9hIu;&P(t4#CM+FnyJgl*wZ|4Pj!Sp0;7^q z&}jSQ0_M{d@2K+(q$V?+phklBTZU#bw#AgxjNGc*|L)$7Q>RX4E=6reOGlCj+5<>A zG9(FUDFwd(K{Y30B#e03ICWHQn**l35uA;!7NR+f$&88!^weXi$_m4U7mn_K{T~|} z8%r?tc+qnhqmj4-W*!~@N07>pBqSN7@n}L2SqX^2r?yIj)Y44MxaL9Ivn1azv#v{B|? zo7*rXBn^`J$f{K&jV{aGDvO{ z(Xj_AXZgzV&%w@Be^eqc{NB{#(GcXr3luX@-zyJLsW1UtF6ioc~u#UG5D&Q zucAisBl79G;sN8@3EjuoT+S^~297NAdDk^9Y5dj4r+3|U+ikHnF9MuNcdvd#WjP$N z^~KAdfnqU*GZvQ>k3o?RM%drR3`M~V-!NLAN6)*Cdp$7eD$d%F35lPe6dH@Rt zn(+GQ|IIybYpyo^H|I1U7?vSjNvBv{F1PZpZeP`L=+L3eEw|j_<@1shv@Kh<9(^O1rC#XsD-e=mh0>UOR%DfRkBy75*fT7)h!HkzjI$i_l0k zpjLx*T1+{7zU-RMFKq03wX+MQ&Pbja9bd6xMe46_zpHh|%=+(0)ZK0DO~ajxLBA2{ECZ;*sA}@;*|Ql4qaKRfTt73ap3Lv3`_u9ctu7eeP{z-~kAZnl!m6^a zA5bb`n-RW5QS~JK6hwX9@qmoMwQbrpeGul}`aWu%Ugp7kKA+NSUs%d?x>zh`pzh}k zNdEjM1;l`>#NEC~uPb!r_=IdoJOrEBBrev(XgoFVi2H)1# zpgC~KfEe>61`h$JuIQz@eW%U51UCxn2k7A#mXS`g zkQNv~VycH!oO$EIbEs)GNH*6^%tOfajiT|6XfvZ*Nzr zSeDD>17fq{#5+P_1sx)_AN?O?5)iMQ7W{Sqm7d zW*`DN&Po|y4Jb>{P|^Ub9eZ~_-+I+mSM?!iz;$ihN+nJJJ7$o77xne^)x$s9yMNKr z6%E-8NS>VJh(0+hU_^F8QIaPWkrF;fblQ1uLVR^4ZrEznQdke^=5<}u7BKTL^aGcY zRt}^+D*|x1&-V{>?f&5p*3XzRqxZAVJ{yMWmG16t+l&{h>PZVxE|+m1oc!r~-A&EQ z8`GK0LIjVYy%V7v7$fRO2I_TI51ohXT1W>eZuG(!;JF8+vy1+HqgfPp7vywOO3@KW z?^#ix!8Vv5*tz?)XIh|QFKFN}#P1b|7;1hG!u?dhAiu+{KAX+XU3Kr;P4ni?yCaiJ z%ak+YEV3}rvx9^#ERz#fT!jAyAJMqb$y{wKu2H*?geM|FLruR-WnPXfU4Bq zfA7%#>zkJ;k}Ro;&0Vv1oZV^EIJqSS%~s?}+Axf&f=$Da z5>rJbNpAbQ_PyEJil9Ml1KLGRN{?pki0smpS6&&Q&3pgYq5aKE(B|cu%|wnRoK!9K zm4Xp2%9L>*@h0SNng}p|a!!vqnWVnd*f?p^P(6*Lm7Js@XdnzdP*w6YHj1|qIU7Y0 z>Rl`Z8`CRDRpxx@o`;^AJ!kG0bKq^0NhN(&l|lqHoPwebK}0A71%^nPtC%1~Z>bg=S@#*&l+Z)%Vi2|842(?dd|% z$0w`SW(3jrU&lzo#8<+lcfwPSLfypWWQr+ta%f?FV|TK*xb52$iuUGXrOYrZ_1x07}3EeLZ6~O~iCd z)GP*GoNVd~8GF{WdMeMUY?=WLC>cesZ93(NafM&huE}B7(>~D)F8+4@E)(&nimE zQ)%w14x>uLDiK*2%y$83Qa!J^=99;&rk|OSs{B3&6xz!EGX}ZsiAU75!

&x75swgRyoHRU*8 z8S@Jw+F@WvDquUXV|~weJhlE@Z(kR79KD*fK|x^W3yj?|#MGL6L4XYbW%kx*8rv2S z%AwzDK+w>(A!z&dbhZF!)~2y>`T)XszFAXkYHGrc6(Bt8dHMOxtq5L8&SBKFRFDiU zBY-g$0ZK3mvT!wtGr)7w5d=!oFzzhb)KFeJ0(4%$03=V_zJ2?+eKlgtsv1*FN@@md zQf+5}!^q@Pa!p3Uu6iP**t1v6o_BwfRFg?QY07~Q#Hi;m*fg-WFtL)C>IvG=0~0KT zk3RYc8Nj%HYGd4iGb9<`C4jU{Jsg^|@~dCpG-uwNJJOjHC$<9-T0gK^vmWOZ` z5$M~Y;Ty0vojQbnX#^&h{sz{sH`ONoP`+9n$%|lyM(ElXwyuVLsE{x9q+u^Ddz}GmIKn=6ZT<) zi3Tnp`|5|kII(~J^-CbD0^lW0V!$lwQx%EQGMa+NA95)IQV!&4IQMA-b}4DC;KBPy zYG^_~A2bop!7F4ALna1boAdWyUHjCm%V&QvSC;}wbBO^OPr1-cxTU5NG?Gul)DTdP z{cpY40tp99LQV>3SSI{~Et>dN!QL2~*Zbl#|I^xk?p#-KxT+Ha#)xri*HlrGCe<@g zl18WShQNEiwewj?IS6Qz^4*b1`_c_?C>&4)ye)F7-XC`U|N3)%!1GE~yDErgPK-y8 zp9Ip&5^w=bNs`+NhEY4Z-|B3|*pvC>c1)qv#g++I)tLLqcfkx*x$7&BNS=r9S4pRl zP^o}G=v7m8j-cY%G*Hj=xm>QNzrWwi5lreQ(Wc^SUIIT~2H*v-ui;virbRbg2M(jz z#icq4DFb%pJ$6RDUBAOE7QVJOLc6dg_B?2mas> z8|N{eTBepJR3(7VL-w^xoIKaR=J%E!O_#gCFH{w@>A z-l3uVJ3T$W+H!F3tL;c`q3$q9T4gFF&6LUZsv{PB0Rud3vbVQ43tI-%7uT%_@U+#z z!9n9W$34sOTVM3T_H%1-P?z7#~t#AZUf8X4E=X}~|#_!7*%WnXN WIKOL*+5%Dl0000 public ColorSlideTransitionHelper(UIElement hostForVisual) { - - - this.hostForVisual = hostForVisual; - // we have an element in the XAML tree that will host our Visuals var visual = ElementCompositionPreview.GetElementVisual(hostForVisual); _compositor = visual.Compositor; diff --git a/WinUIGallery/Common/MenuItemTemplateSelector.cs b/WinUIGallery/Common/MenuItemTemplateSelector.cs index 62e30580f..6ae43e0f9 100644 --- a/WinUIGallery/Common/MenuItemTemplateSelector.cs +++ b/WinUIGallery/Common/MenuItemTemplateSelector.cs @@ -1,4 +1,4 @@ -using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Markup; using System; @@ -11,8 +11,6 @@ class MenuItemTemplateSelector : DataTemplateSelector { public DataTemplate ItemTemplate { get; set; } - //public string PaneTitle { get; set; } - protected override DataTemplate SelectTemplateCore(object item) { return item is Separator ? SeparatorTemplate : item is Header ? HeaderTemplate : ItemTemplate; diff --git a/WinUIGallery/Common/Win32.cs b/WinUIGallery/Common/Win32.cs index 6fa9424e6..1146c78a1 100644 --- a/WinUIGallery/Common/Win32.cs +++ b/WinUIGallery/Common/Win32.cs @@ -19,7 +19,6 @@ internal static class Win32 public const int WM_ACTIVATE = 0x0006; public const int WA_ACTIVE = 0x01; - //static int WA_CLICKACTIVE = 0x02; public const int WA_INACTIVE = 0x00; public const int WM_SETICON = 0x0080; diff --git a/WinUIGallery/Common/WrapPanel.cs b/WinUIGallery/Common/WrapPanel.cs index 5a2c1b26d..914e2dc25 100644 --- a/WinUIGallery/Common/WrapPanel.cs +++ b/WinUIGallery/Common/WrapPanel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -38,7 +38,6 @@ public class WrapPanel : Panel /// within a . The /// default value is . /// - //[TypeConverter(typeof(LengthConverter))] public double ItemHeight { get { return (double)GetValue(ItemHeightProperty); } @@ -73,7 +72,6 @@ public double ItemHeight /// contained in a . /// The default value is . /// - //[TypeConverter(typeof(LengthConverter))] public double ItemWidth { get { return (double)GetValue(ItemWidthProperty); } diff --git a/WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml b/WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml index 7f8686b0a..d179cceb3 100644 --- a/WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml +++ b/WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml @@ -1,4 +1,4 @@ - - - - + + - + diff --git a/WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml.cs b/WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml.cs index 5577dfed4..b852a902c 100644 --- a/WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml.cs +++ b/WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media.Animation; @@ -59,8 +59,7 @@ private void collection_ItemClick(object sender, ItemClickEventArgs e) // Prepare the connected animation. // Notice that the stored item is passed in, as well as the name of the connected element. // The animation will actually start on the Detailed info page. - var animation = collection.PrepareConnectedAnimation("ForwardConnectedAnimation", _storeditem, "connectedElement"); - + collection.PrepareConnectedAnimation("ForwardConnectedAnimation", _storeditem, "connectedElement"); } // Navigate to the DetailedInfoPage. @@ -68,5 +67,12 @@ private void collection_ItemClick(object sender, ItemClickEventArgs e) Frame.Navigate(typeof(DetailedInfoPage), _storeditem, new SuppressNavigationTransitionInfo()); } + private void TextBlock_IsTextTrimmedChanged(TextBlock sender, IsTextTrimmedChangedEventArgs args) + { + var textBlock = sender as TextBlock; + var text = textBlock.IsTextTrimmed ? textBlock.Text : string.Empty; + + ToolTipService.SetToolTip(textBlock, text); + } } } diff --git a/WinUIGallery/ContentIncludes.props b/WinUIGallery/ContentIncludes.props index c886bc462..467eb0f1e 100644 --- a/WinUIGallery/ContentIncludes.props +++ b/WinUIGallery/ContentIncludes.props @@ -103,6 +103,7 @@ + @@ -150,6 +151,7 @@ + @@ -302,6 +304,8 @@ + + @@ -368,7 +372,8 @@ + - \ No newline at end of file + diff --git a/WinUIGallery/ControlPages/AnnotatedScrollBarPage.xaml.cs b/WinUIGallery/ControlPages/AnnotatedScrollBarPage.xaml.cs index 5f0336140..e66687201 100644 --- a/WinUIGallery/ControlPages/AnnotatedScrollBarPage.xaml.cs +++ b/WinUIGallery/ControlPages/AnnotatedScrollBarPage.xaml.cs @@ -8,6 +8,7 @@ // //********************************************************* +using System; using System.Collections.ObjectModel; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls.Primitives; @@ -181,7 +182,7 @@ private string GetItemColor(int itemIndex) private int GetItemsPerRow() { - return (itemsRepeater == null || itemsRepeater.ActualWidth == 0) ? 1 : (int) (itemsRepeater.ActualWidth / ItemWidth); + return (itemsRepeater == null || itemsRepeater.ActualWidth == 0) ? 1 : (int) Math.Max(itemsRepeater.ActualWidth / ItemWidth, 1); } } } diff --git a/WinUIGallery/ControlPages/AppBarSeparatorPage.xaml.cs b/WinUIGallery/ControlPages/AppBarSeparatorPage.xaml.cs index f3c7b0267..5d5810848 100644 --- a/WinUIGallery/ControlPages/AppBarSeparatorPage.xaml.cs +++ b/WinUIGallery/ControlPages/AppBarSeparatorPage.xaml.cs @@ -20,16 +20,5 @@ public AppBarSeparatorPage() { this.InitializeComponent(); } - private void CompactButton_Click(object sender, RoutedEventArgs e) - { - if ((sender as AppBarToggleButton).IsChecked == true) - { - Control1.DefaultLabelPosition = CommandBarDefaultLabelPosition.Collapsed; - } - else - { - Control1.DefaultLabelPosition = CommandBarDefaultLabelPosition.Bottom; - } - } } } diff --git a/WinUIGallery/ControlPages/AppBarToggleButtonPage.xaml.cs b/WinUIGallery/ControlPages/AppBarToggleButtonPage.xaml.cs index fed643b34..195750aa8 100644 --- a/WinUIGallery/ControlPages/AppBarToggleButtonPage.xaml.cs +++ b/WinUIGallery/ControlPages/AppBarToggleButtonPage.xaml.cs @@ -21,17 +21,6 @@ public AppBarToggleButtonPage() this.InitializeComponent(); } - private void CompactButton_Click(object sender, RoutedEventArgs e) - { - if (sender is ToggleButton toggle && toggle.IsChecked != null) - { - Button1.IsCompact = - Button2.IsCompact = - Button3.IsCompact = - Button4.IsCompact = (bool)toggle.IsChecked; - } - } - private void AppBarButton_Click(object sender, RoutedEventArgs e) { if (sender is AppBarToggleButton b) diff --git a/WinUIGallery/ControlPages/CaptureElementPreviewPage.xaml b/WinUIGallery/ControlPages/CaptureElementPreviewPage.xaml new file mode 100644 index 000000000..918b45f76 --- /dev/null +++ b/WinUIGallery/ControlPages/CaptureElementPreviewPage.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + - + + + + + - - - + + + - - - + + + - - - + + + - - - + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WinUIGallery/ControlPages/FilePickerPage.xaml.cs b/WinUIGallery/ControlPages/FilePickerPage.xaml.cs index 01308d481..f0a393996 100644 --- a/WinUIGallery/ControlPages/FilePickerPage.xaml.cs +++ b/WinUIGallery/ControlPages/FilePickerPage.xaml.cs @@ -60,12 +60,14 @@ private async void PickAFileButton_Click(object sender, RoutedEventArgs e) span.Inlines.Add(run1); span.Inlines.Add(run2); - PickAFileOutputTextBlock.Inlines.Add(span); + PickAFileOutputTextBlock.Inlines.Add(span); } else { PickAFileOutputTextBlock.Text = "Operation cancelled."; } + + UIHelper.AnnounceActionForAccessibility(sender as Button, PickAFileOutputTextBlock.Text, "FilePickedNotificationId"); } private async void PickAPhotoButton_Click(object sender, RoutedEventArgs e) { @@ -111,6 +113,8 @@ private async void PickAPhotoButton_Click(object sender, RoutedEventArgs e) { PickAPhotoOutputTextBlock.Text = "Operation cancelled."; } + + UIHelper.AnnounceActionForAccessibility(sender as Button, PickAPhotoOutputTextBlock.Text, "PhotoPickedNotificationId"); } private async void PickFilesButton_Click(object sender, RoutedEventArgs e) @@ -159,6 +163,8 @@ private async void PickFilesButton_Click(object sender, RoutedEventArgs e) { PickFilesOutputTextBlock.Text = "Operation cancelled."; } + + UIHelper.AnnounceActionForAccessibility(sender as Button, PickFilesOutputTextBlock.Text, "FilesPickedNotificationId"); } private async void PickFolderButton_Click(object sender, RoutedEventArgs e) @@ -204,6 +210,8 @@ private async void PickFolderButton_Click(object sender, RoutedEventArgs e) { PickFolderOutputTextBlock.Text = "Operation cancelled."; } + + UIHelper.AnnounceActionForAccessibility(sender as Button, PickFolderOutputTextBlock.Text, "FolderPickedNotificationId"); } private async void SaveFileButton_Click(object sender, RoutedEventArgs e) @@ -269,7 +277,8 @@ private async void SaveFileButton_Click(object sender, RoutedEventArgs e) { SaveFileOutputTextBlock.Text = "Operation cancelled."; } - } + UIHelper.AnnounceActionForAccessibility(sender as Button, SaveFileOutputTextBlock.Text, "FileSavedNotificationId"); + } } } diff --git a/WinUIGallery/ControlPages/GridViewPage.xaml b/WinUIGallery/ControlPages/GridViewPage.xaml index 14af410c2..26996faf7 100644 --- a/WinUIGallery/ControlPages/GridViewPage.xaml +++ b/WinUIGallery/ControlPages/GridViewPage.xaml @@ -104,7 +104,7 @@ - @@ -155,7 +155,7 @@ some parts of the GridViewItems (i.e. the margins). --> ItemTemplate="{StaticResource ImageOverlayTemplate}"> <GridView.ItemContainerStyle> - <Style TargetType="GridViewItem"> + <Style TargetType="GridViewItem" BasedOn="{StaticResource DefaultGridViewItemStyle}"> <Setter Property="Margin" Value="$(ColMargin), $(RowMargin), $(ColMargin), $(RowMargin)"/> </Style> </GridView.ItemContainerStyle> diff --git a/WinUIGallery/ControlPages/InfoBadgePage.xaml b/WinUIGallery/ControlPages/InfoBadgePage.xaml index e9f32e00f..8b555c112 100644 --- a/WinUIGallery/ControlPages/InfoBadgePage.xaml +++ b/WinUIGallery/ControlPages/InfoBadgePage.xaml @@ -31,7 +31,7 @@ - + @@ -55,7 +55,7 @@ -<NavigationViewItem x:Name="InboxPage" Content="Inbox" Icon="Mail"> +<NavigationViewItem x:Name="InboxPage" Content="Inbox" Icon="Mail" AutomationProperties.Name="Inbox, 5 notifications"> <NavigationViewItem.InfoBadge> <InfoBadge x:Name="infoBadge1" Value="5" Opacity="{x:Bind InfoBadgeOpacity, Mode=OneWay}"/> </NavigationViewItem.InfoBadge> @@ -67,9 +67,11 @@ - + - + @@ -86,9 +88,13 @@ -<InfoBadge x:Name="infoBadge2" Style="{StaticResource $(Style)IconInfoBadgeStyle}" /> -<InfoBadge x:Name="infoBadge3" Style="{StaticResource $(Style)ValueInfoBadgeStyle}" Value="10" /> -<InfoBadge x:Name="infoBadge4" Style="{StaticResource $(Style)DotInfoBadgeStyle}" /> +<StackPanel Orientation="Horizontal" contract5Present:Spacing="20" HorizontalAlignment="Center"/> + <InfoBadge x:Name="infoBadge2" Style="{StaticResource $(Style)IconInfoBadgeStyle}" HorizontalAlignment="Right" + AutomationProperties.Name="Warning badge" AutomationProperties.AutomationControlType="Image"/> + <InfoBadge x:Name="infoBadge3" Style="{StaticResource $(Style)ValueInfoBadgeStyle}" HorizontalAlignment="Right" Value="10" /> + <InfoBadge x:Name="infoBadge4" Style="{StaticResource $(Style)DotInfoBadgeStyle}" VerticalAlignment="Center" + AutomationProperties.Name="Notification badge" AutomationProperties.AutomationControlType="Image"/> +</StackPanel> @@ -99,7 +105,7 @@ - diff --git a/WinUIGallery/ControlPages/ItemsRepeaterPage.xaml.cs b/WinUIGallery/ControlPages/ItemsRepeaterPage.xaml.cs index 82bea3597..eca2b7f2f 100644 --- a/WinUIGallery/ControlPages/ItemsRepeaterPage.xaml.cs +++ b/WinUIGallery/ControlPages/ItemsRepeaterPage.xaml.cs @@ -25,8 +25,6 @@ public sealed partial class ItemsRepeaterPage : ItemsPageBase public List staticRecipeData; private bool IsSortDescending = false; - private double AnimatedBtnHeight; - private Thickness AnimatedBtnMargin; private Button LastSelectedColorButton; private int PreviouslyFocusedAnimatedScrollRepeaterIndex = -1; @@ -316,13 +314,6 @@ private void OnElementPrepared(Microsoft.UI.Xaml.Controls.ItemsRepeater sender, item.StartAnimation("CenterPoint", centerPointExpression); } - private void GetButtonSize(object sender, RoutedEventArgs e) - { - Button AnimatedBtn = sender as Button; - AnimatedBtnHeight = AnimatedBtn.ActualHeight; - AnimatedBtnMargin = AnimatedBtn.Margin; - } - private void SetUIANamesForSelectedEntry(Button selectedItem) { if (LastSelectedColorButton != null && LastSelectedColorButton.Content is string content) @@ -334,27 +325,6 @@ private void SetUIANamesForSelectedEntry(Button selectedItem) LastSelectedColorButton = selectedItem; } - // Find centerpoint of ScrollViewer - private double CenterPointOfViewportInExtent() - { - return Animated_ScrollViewer.VerticalOffset + Animated_ScrollViewer.ViewportHeight / 2; - } - - // Find index of the item that's at the center of the viewport - private int GetSelectedIndexFromViewport() - { - int selectedItemIndex = (int)Math.Floor(CenterPointOfViewportInExtent() / ((double)AnimatedBtnMargin.Top + AnimatedBtnHeight)); - selectedItemIndex %= animatedScrollRepeater.ItemsSourceView.Count; - return selectedItemIndex; - } - - // Return item that's currently in center of viewport - private object GetSelectedItemFromViewport() - { - var selectedIndex = GetSelectedIndexFromViewport(); - var selectedElement = animatedScrollRepeater.TryGetElement(selectedIndex) as Button; - return selectedElement; - } // ========================================================================== // VariedImageSize Layout with Filtering/Sorting diff --git a/WinUIGallery/ControlPages/ItemsViewPage.xaml b/WinUIGallery/ControlPages/ItemsViewPage.xaml index 6da2b0b89..e1bbaaf29 100644 --- a/WinUIGallery/ControlPages/ItemsViewPage.xaml +++ b/WinUIGallery/ControlPages/ItemsViewPage.xaml @@ -137,24 +137,25 @@ private void BasicItemsView_ItemInvoked(ItemsView sender, ItemsViewItemInvokedEv - - - + + GroupName="ItemsViewLayouts" + FontWeight="Normal"/> + GroupName="ItemsViewLayouts" + FontWeight="Normal"/> diff --git a/WinUIGallery/ControlPages/ListViewPage.xaml b/WinUIGallery/ControlPages/ListViewPage.xaml index 690f71129..7265f18a1 100644 --- a/WinUIGallery/ControlPages/ListViewPage.xaml +++ b/WinUIGallery/ControlPages/ListViewPage.xaml @@ -337,9 +337,9 @@ source code for the WinUI Gallery. --> sent or received, and those values are bound in the DataTemplate.--> <DataTemplate x:Key="MessageViewTemplate" x:DataType="local1:Message"> <Grid Height="Auto" Margin="4" HorizontalAlignment="{x:Bind MsgAlignment}"> - <StackPanel MinHeight="75" Width="350" Padding="10, 0, 0, 10" Background="{x:Bind BgColor}" CornerRadius="{StaticResource ControlCornerRadius}"> - <TextBlock Text="{x:Bind MsgText}" Padding="0, 10, 0, 0" FontSize="20" Foreground="{ThemeResource SystemControlForegroundAltHighBrush}"/> - <TextBlock Text="{x:Bind MsgDateTime}" Padding="0, 0, 0, 10" FontSize="15" Foreground="{ThemeResource SystemControlForegroundAltMediumHighBrush}"/> + <StackPanel MinHeight="75" Width="350" Padding="10, 0, 0, 10" Background="{ThemeResource SystemColorHighlightColor}" CornerRadius="{StaticResource ControlCornerRadius}"> + <TextBlock Text="{x:Bind MsgText}" Padding="0, 10, 0, 0" FontSize="20" Foreground="{ThemeResource SystemColorHighlightTextColor}"/> + <TextBlock Text="{x:Bind MsgDateTime}" Padding="0, 0, 0, 10" FontSize="15" Foreground="{ThemeResource SystemColorHighlightTextColor}"/> </StackPanel> </Grid> </DataTemplate> @@ -378,7 +378,8 @@ sent or received, and those values are bound in the DataTemplate.--> + Width="350" MaxHeight="60" Margin="0,0,0,10" + TextTrimming="CharacterEllipsis" TextWrapping="Wrap" IsTextTrimmedChanged="TextBlock_IsTextTrimmedChanged"/> diff --git a/WinUIGallery/ControlPages/ListViewPage.xaml.cs b/WinUIGallery/ControlPages/ListViewPage.xaml.cs index 00a811d7b..f74c596b5 100644 --- a/WinUIGallery/ControlPages/ListViewPage.xaml.cs +++ b/WinUIGallery/ControlPages/ListViewPage.xaml.cs @@ -323,6 +323,18 @@ private void MessageReceived(object sender, RoutedEventArgs e) new Message("Message " + ++messageNumber, DateTime.Now, HorizontalAlignment.Left) ); } + + //=================================================================================================================== + // ListView with Images Sample + //=================================================================================================================== + + private void TextBlock_IsTextTrimmedChanged(TextBlock sender, IsTextTrimmedChangedEventArgs args) + { + var textBlock = sender as TextBlock; + var text = textBlock.IsTextTrimmed ? textBlock.Text : string.Empty; + + ToolTipService.SetToolTip(textBlock, text); + } } public class Message diff --git a/WinUIGallery/ControlPages/MenuBarPage.xaml b/WinUIGallery/ControlPages/MenuBarPage.xaml index a1eb2b234..281f8b3a1 100644 --- a/WinUIGallery/ControlPages/MenuBarPage.xaml +++ b/WinUIGallery/ControlPages/MenuBarPage.xaml @@ -12,7 +12,7 @@ XamlSource="MenuBar\MenuBarSample1.txt"> - + @@ -38,7 +38,7 @@ XamlSource="Menubar\MenuBarSample3.txt"> - + @@ -101,7 +101,7 @@ XamlSource="MenuBar\MenuBarSample2.txt"> - + diff --git a/WinUIGallery/ControlPages/MenuBarPage.xaml.cs b/WinUIGallery/ControlPages/MenuBarPage.xaml.cs index 3ad806772..4c1dc1005 100644 --- a/WinUIGallery/ControlPages/MenuBarPage.xaml.cs +++ b/WinUIGallery/ControlPages/MenuBarPage.xaml.cs @@ -1,5 +1,4 @@ -using AppUIBasics.Helper; -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -39,15 +38,6 @@ private void OnElementClicked(object sender, Microsoft.UI.Xaml.RoutedEventArgs e { SelectedOptionText2.Text = "You clicked: " + (sender as MenuFlyoutItem).Text; } - } - - // Workaround for known issue with menu themes in WinAppSDK 1.4 (#8678, #8756) - private void MenuBar_LayoutUpdated(object sender, object e) - { - foreach (var popup in VisualTreeHelper.GetOpenPopupsForXamlRoot(this.XamlRoot)) - { - popup.RequestedTheme = ThemeHelper.RootTheme; - } - } + } } } diff --git a/WinUIGallery/ControlPages/MenuFlyoutPage.xaml b/WinUIGallery/ControlPages/MenuFlyoutPage.xaml index fe11972b4..d907ce671 100644 --- a/WinUIGallery/ControlPages/MenuFlyoutPage.xaml +++ b/WinUIGallery/ControlPages/MenuFlyoutPage.xaml @@ -1,4 +1,4 @@ - Click="Animated_GotItem" GotFocus="Animated_GotItem" HorizontalAlignment="Stretch" - Loaded="GetButtonSize" Foreground="{ThemeResource ButtonForeground}"/> diff --git a/WinUIGallery/ControlPagesSampleCode/Media/CaptureElementPreviewSample_cs.txt b/WinUIGallery/ControlPagesSampleCode/Media/CaptureElementPreviewSample_cs.txt new file mode 100644 index 000000000..3b6e0ecd6 --- /dev/null +++ b/WinUIGallery/ControlPagesSampleCode/Media/CaptureElementPreviewSample_cs.txt @@ -0,0 +1,48 @@ +using Windows.Media.Capture.Frames; +using Windows.Media.Capture; + + private MediaFrameSourceGroup mediaFrameSourceGroup; + private MediaCapture mediaCapture; + + async private void StartCaptureElement() + { + var groups = await MediaFrameSourceGroup.FindAllAsync(); + if (groups.Count == 0) + { + frameSourceName.Text = "No camera devices found."; + return; + } + mediaFrameSourceGroup = groups.First(); + + frameSourceName.Text = "Viewing: " + mediaFrameSourceGroup.DisplayName; + mediaCapture = new MediaCapture(); + var mediaCaptureInitializationSettings = new MediaCaptureInitializationSettings() + { + SourceGroup = this.mediaFrameSourceGroup, + SharingMode = MediaCaptureSharingMode.SharedReadOnly, + StreamingCaptureMode = StreamingCaptureMode.Video, + MemoryPreference = MediaCaptureMemoryPreference.Cpu + }; + await mediaCapture.InitializeAsync(mediaCaptureInitializationSettings); + + // Set the MediaPlayerElement's Source property to the MediaSource for the mediaCapture. + var frameSource = mediaCapture.FrameSources[this.mediaFrameSourceGroup.SourceInfos[0].Id]; + captureElement.Source = Windows.Media.Core.MediaSource.CreateFromMediaFrameSource(frameSource); +$(MirrorPreview) } + + async private void CapturePhoto_Click(object sender, RoutedEventArgs e) + { + // Capture a photo to a stream + var imgFormat = ImageEncodingProperties.CreateJpeg(); + var stream = new InMemoryRandomAccessStream(); + await mediaCapture.CapturePhotoToStreamAsync(imgFormat, stream); + stream.Seek(0); + + // Show the photo in an Image element + BitmapImage bmpImage = new BitmapImage(); + await bmpImage.SetSourceAsync(stream); + var image = new Image() { Source = bmpImage }; + snapshots.Children.Insert(0, image); + + capturedText.Visibility = Visibility.Visible; + } diff --git a/WinUIGallery/ControlPagesSampleCode/Media/CaptureElementPreviewSample_xaml.txt b/WinUIGallery/ControlPagesSampleCode/Media/CaptureElementPreviewSample_xaml.txt new file mode 100644 index 000000000..bbc4e453d --- /dev/null +++ b/WinUIGallery/ControlPagesSampleCode/Media/CaptureElementPreviewSample_xaml.txt @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/WinUIGallery/ControlPagesSampleCode/Motion/ConnectedAnimation/ConnectedAnimationSample1_cs.txt b/WinUIGallery/ControlPagesSampleCode/Motion/ConnectedAnimation/ConnectedAnimationSample1_cs.txt index dcd9af9db..a3b36842d 100644 --- a/WinUIGallery/ControlPagesSampleCode/Motion/ConnectedAnimation/ConnectedAnimationSample1_cs.txt +++ b/WinUIGallery/ControlPagesSampleCode/Motion/ConnectedAnimation/ConnectedAnimationSample1_cs.txt @@ -54,8 +54,7 @@ public sealed partial class CollectionPage : Page // Prepare the connected animation. // Notice that the stored item is passed in, as well as the name of the connected element. // The animation will actually start on the Detailed info page. - var animation = collection.PrepareConnectedAnimation("ForwardConnectedAnimation", _storeditem, "connectedElement"); - + collection.PrepareConnectedAnimation("ForwardConnectedAnimation", _storeditem, "connectedElement"); } // Navigate to the DetailedInfoPage. diff --git a/WinUIGallery/ControlPagesSampleCode/SystemBackdrops/SystemBackdropsSample1.txt b/WinUIGallery/ControlPagesSampleCode/SystemBackdrops/SystemBackdropsSample1.txt index 357e01e7c..5606bd3b5 100644 --- a/WinUIGallery/ControlPagesSampleCode/SystemBackdrops/SystemBackdropsSample1.txt +++ b/WinUIGallery/ControlPagesSampleCode/SystemBackdrops/SystemBackdropsSample1.txt @@ -5,7 +5,7 @@ WindowsSystemDispatcherQueueHelper m_wsdqHelper; // See separate sample below fo Microsoft.UI.Composition.SystemBackdrops.MicaController m_micaController; Microsoft.UI.Composition.SystemBackdrops.SystemBackdropConfiguration m_configurationSource; -bool TrySetMicaBackdrop() +bool TrySetMicaBackdrop(bool useMicaAlt) { if (Microsoft.UI.Composition.SystemBackdrops.MicaController.IsSupported()) { @@ -24,6 +24,8 @@ bool TrySetMicaBackdrop() m_micaController = new Microsoft.UI.Composition.SystemBackdrops.MicaController(); + m_micaController.Kind = useMicaAlt ? Microsoft.UI.Composition.SystemBackdrops.MicaKind.BaseAlt : Microsoft.UI.Composition.SystemBackdrops.MicaKind.Base; + // Enable the system backdrop. // Note: Be sure to have "using WinRT;" to support the Window.As<...>() call. m_micaController.AddSystemBackdropTarget(this.As()); diff --git a/WinUIGallery/ControlPagesSampleCode/SystemBackdrops/SystemBackdropsSample2.txt b/WinUIGallery/ControlPagesSampleCode/SystemBackdrops/SystemBackdropsSample2.txt index 0a14ad08a..f47c55ac2 100644 --- a/WinUIGallery/ControlPagesSampleCode/SystemBackdrops/SystemBackdropsSample2.txt +++ b/WinUIGallery/ControlPagesSampleCode/SystemBackdrops/SystemBackdropsSample2.txt @@ -5,7 +5,7 @@ WindowsSystemDispatcherQueueHelper m_wsdqHelper; // See separate sample below fo Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController m_acrylicController; Microsoft.UI.Composition.SystemBackdrops.SystemBackdropConfiguration m_configurationSource; -bool TrySetAcrylicBackdrop() +bool TrySetAcrylicBackdrop(bool useAcrylicThin) { if (Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController.IsSupported()) { @@ -24,6 +24,8 @@ bool TrySetAcrylicBackdrop() m_acrylicController = new Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController(); + m_acrylicController.Kind = useAcrylicThin ? Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicKind.Thin : Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicKind.Base; + // Enable the system backdrop. // Note: Be sure to have "using WinRT;" to support the Window.As<...>() call. m_acrylicController.AddSystemBackdropTarget(this.As()); diff --git a/WinUIGallery/ControlPagesSampleCode/Text/RichEditBox/RichEditBoxSample3_cs.txt b/WinUIGallery/ControlPagesSampleCode/Text/RichEditBox/RichEditBoxSample3_cs.txt index 9ee56c174..3e43ca381 100644 --- a/WinUIGallery/ControlPagesSampleCode/Text/RichEditBox/RichEditBoxSample3_cs.txt +++ b/WinUIGallery/ControlPagesSampleCode/Text/RichEditBox/RichEditBoxSample3_cs.txt @@ -111,7 +111,7 @@ private void FindBoxRemoveHighlights() private void Editor_GotFocus(object sender, RoutedEventArgs e) { - editor.Document.GetText(TextGetOptions.UseCrlf, out string currentRawText); + editor.Document.GetText(TextGetOptions.UseCrlf, out _); // reset colors to correct defaults for Focused state ITextRange documentRange = editor.Document.GetRange(0, TextConstants.MaxUnitCount); diff --git a/WinUIGallery/ControlPagesSampleCode/Window/CreateWindowSample1.txt b/WinUIGallery/ControlPagesSampleCode/Window/CreateWindowSample1.txt index 7f5890faf..938d39d2f 100644 --- a/WinUIGallery/ControlPagesSampleCode/Window/CreateWindowSample1.txt +++ b/WinUIGallery/ControlPagesSampleCode/Window/CreateWindowSample1.txt @@ -6,6 +6,6 @@ newWindow.Content = rootPage; newWindow.Activate(); // C# code to navigate in the new window -var targetPageType = typeof(NewControlsPage); +var targetPageType = typeof(HomePage); string targetPageArguments = string.Empty; rootPage.Navigate(targetPageType, targetPageArguments); \ No newline at end of file diff --git a/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample2.txt b/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample2.txt index 752e3b23f..d6bcc6eaf 100644 --- a/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample2.txt +++ b/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample2.txt @@ -1,4 +1,4 @@ -// no UIElement is set for titlebar, fallback titlebar is created +// no UIElement is set for titlebar, default titlebar is created which extends to entire non client area Window window = App.MainWindow; window.ExtendsContentIntoTitleBar = true; -window.SetTitleBar(null); // this line is optional as by it is null by default +// window.SetTitleBar(null); // optional line as not setting any UIElement as titlebar is same as setting null as titlebar diff --git a/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample3.txt b/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample3.txt new file mode 100644 index 000000000..f3afd4b40 --- /dev/null +++ b/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample3.txt @@ -0,0 +1,22 @@ +Window window = App.MainWindow; +window.ExtendsContentIntoTitleBar = true; +window.SetTitleBar(AppTitleBar); +var nonClientInputSrc = InputNonClientPointerSource.GetForWindowId(window.AppWindow.Id); + +// textbox on titlebar area +var txtBoxNonClientArea = UIHelper.FindElementByName(sender as UIElement, "AppTitleBarTextBox") as FrameworkElement; +GeneralTransform transformTxtBox = txtBoxNonClientArea.TransformToVisual(null); +Rect bounds = transformTxtBox.TransformBounds(new Rect(0, 0, txtBoxNonClientArea.ActualWidth, txtBoxNonClientArea.ActualHeight)); + +// Windows.Graphics.RectInt32[] rects defines the area which allows click throughs in custom titlebar +// it is non dpi-aware client coordinates. Hence, we convert dpi aware coordinates to non-dpi coordinates +var scale = WindowHelper.GetRasterizationScaleForElement(this); +var transparentRect = new Windows.Graphics.RectInt32( + _X: (int)Math.Round(bounds.X * scale), + _Y: (int)Math.Round(bounds.Y * scale), + _Width: (int)Math.Round(bounds.Width * scale), + _Height: (int)Math.Round(bounds.Height * scale) +); +var rects = new Windows.Graphics.RectInt32[] { transparentRect }; + +nonClientInputSrc.SetRegionRects(NonClientRegionKind.Passthrough, rects); // areas defined will be click through and can host button and textboxes diff --git a/WinUIGallery/Controls/ControlExample.xaml b/WinUIGallery/Controls/ControlExample.xaml index c62b28310..6b2e8c008 100644 --- a/WinUIGallery/Controls/ControlExample.xaml +++ b/WinUIGallery/Controls/ControlExample.xaml @@ -80,7 +80,7 @@ IsTextSelectionEnabled="True" Visibility="Collapsed"> - This sample requires a later version of Windows to be fully functional. Learn more about version adaptive apps:https://learn.microsoft.com/windows/uwp/debug-test-perf/version-adaptive-apps + This sample requires a later version of Windows to be fully functional. diff --git a/WinUIGallery/Controls/DesignGuidance/ColorTile.xaml.cs b/WinUIGallery/Controls/DesignGuidance/ColorTile.xaml.cs index 5e66dbc69..0e757b94f 100644 --- a/WinUIGallery/Controls/DesignGuidance/ColorTile.xaml.cs +++ b/WinUIGallery/Controls/DesignGuidance/ColorTile.xaml.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. +using AppUIBasics.Helper; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Input; @@ -75,6 +76,7 @@ private void CopyBrushNameButton_Click(object sender, RoutedEventArgs e) package.SetText(ColorBrushName); Clipboard.SetContent(package); + UIHelper.AnnounceActionForAccessibility(sender as Button, "Brush name copied to clipboard", "BrushNameCopiedSuccessNotificationId"); } } } diff --git a/WinUIGallery/Controls/HeaderTile.xaml.cs b/WinUIGallery/Controls/HeaderTile.xaml.cs index 3a5c643bf..2f58e80f4 100644 --- a/WinUIGallery/Controls/HeaderTile.xaml.cs +++ b/WinUIGallery/Controls/HeaderTile.xaml.cs @@ -22,9 +22,6 @@ namespace AppUIBasics.Controls { public sealed partial class HeaderTile : UserControl { - Compositor _compositor = Microsoft.UI.Xaml.Media.CompositionTarget.GetCompositorForCurrentThread(); - private SpringVector3NaturalMotionAnimation _springAnimation; - public string Title { get { return (string)GetValue(TitleProperty); } @@ -66,33 +63,5 @@ public HeaderTile() { this.InitializeComponent(); } - - private void Element_PointerEntered(object sender, PointerRoutedEventArgs e) - { - CreateOrUpdateSpringAnimation(1.1f); - (sender as UIElement).CenterPoint = new Vector3(70, 40, 1f); - (sender as UIElement).StartAnimation(_springAnimation); - } - - private void Element_PointerExited(object sender, PointerRoutedEventArgs e) - { - CreateOrUpdateSpringAnimation(1.0f); - (sender as UIElement).CenterPoint = new Vector3(70, 40, 1f); - (sender as UIElement).StartAnimation(_springAnimation); - } - - private void CreateOrUpdateSpringAnimation(float finalValue) - { - if (_springAnimation == null) - { - if (_compositor != null) - { - _springAnimation = _compositor.CreateSpringVector3Animation(); - _springAnimation.Target = "Scale"; - } - } - - _springAnimation.FinalValue = new Vector3(finalValue); - } } } diff --git a/WinUIGallery/Controls/PageHeader.xaml b/WinUIGallery/Controls/PageHeader.xaml index c1e606c91..6e68235f1 100644 --- a/WinUIGallery/Controls/PageHeader.xaml +++ b/WinUIGallery/Controls/PageHeader.xaml @@ -142,7 +142,7 @@ Subtitle="Share with others or paste this link into the Run dialog to open the app to this page directly." Target="{x:Bind CopyLinkButton}"> - + diff --git a/WinUIGallery/Controls/SampleCodePresenter.xaml.cs b/WinUIGallery/Controls/SampleCodePresenter.xaml.cs index 129127c4f..0c61cd4ef 100644 --- a/WinUIGallery/Controls/SampleCodePresenter.xaml.cs +++ b/WinUIGallery/Controls/SampleCodePresenter.xaml.cs @@ -25,6 +25,7 @@ using AppUIBasics.Common; using System.Reflection; using System.IO; +using Microsoft.UI.Xaml.Automation; namespace AppUIBasics.Controls { @@ -66,7 +67,7 @@ public IList Substitutions set { SetValue(SubstitutionsProperty, value); } } - public bool IsEmpty => Code.Length == 0 && CodeSourceFile == null; + public bool IsEmpty => string.IsNullOrEmpty(Code) && string.IsNullOrEmpty(CodeSourceFile); private string actualCode = ""; private static Regex SubstitutionPattern = new Regex(@"\$\(([^\)]+)\)"); @@ -87,7 +88,7 @@ private static void OnDependencyPropertyChanged(DependencyObject target, Depende private void ReevaluateVisibility() { - if (Code.Length == 0 && CodeSourceFile == null) + if (IsEmpty) { Visibility = Visibility.Collapsed; } @@ -226,6 +227,10 @@ private void FormatAndRenderSampleFromString(string sampleString, ContentPresent actualCode = sampleString; + var name = GetSampleLanguageVisualState() == "InlineSample" ? actualCode : SampleHeader.Text; + var automationName = "Copy " + name + " Code"; + AutomationProperties.SetName(CopyCodeButton, automationName); + var formatter = GenerateRichTextFormatter(); if (SampleType == SampleCodePresenterType.Inline) diff --git a/WinUIGallery/DataModel/ControlInfoData.json b/WinUIGallery/DataModel/ControlInfoData.json index 9ea25af16..9e480e4c7 100644 --- a/WinUIGallery/DataModel/ControlInfoData.json +++ b/WinUIGallery/DataModel/ControlInfoData.json @@ -56,7 +56,8 @@ { "Title": "Colors in Windows 11", "Uri": "https://learn.microsoft.com/windows/apps/design/signature-experiences/color" - },{ + }, + { "Title": "Windows UI Toolkit (Figma)", "Uri": "https://www.figma.com/community/file/1159947337437047524" }, @@ -65,10 +66,20 @@ "Uri": "https://github.com/microsoft/microsoft-ui-xaml/blob/main/dev/CommonStyles/Common_themeresources_any.xaml" } ] - }, + } + ] + }, + { + "UniqueId": "AccessibilityItem", + "Title": "Accessibility", + "ImagePath": "ms-appx:///Assets/ControlImages/Placeholder.png", + "ImageIconPath": "ms-appx:///Assets/ControlIcons/DefaultIcon.png", + "IsSpecialSection": true, + "Folder": "Accessibility", + "Items": [ { "UniqueId": "AccessibilityColorContrast", - "Title": "Color contrast", + "Title": "Color Contrast", "ImagePath": "ms-appx:///Assets/ControlImages/AppBarSeparator.png", "ImageIconPath": "ms-appx:///Assets/ControlIcons/AppBarSeparatorIcon.png", "HideSourceCodeAndRelatedControls": true, @@ -85,7 +96,7 @@ }, { "UniqueId": "AccessibilityKeyboard", - "Title": "Keyboard support", + "Title": "Keyboard Support", "ImagePath": "ms-appx:///Assets/ControlImages/AppBarSeparator.png", "ImageIconPath": "ms-appx:///Assets/ControlIcons/AppBarSeparatorIcon.png", "HideSourceCodeAndRelatedControls": true, @@ -126,7 +137,7 @@ }, { "UniqueId": "AccessibilityScreenReader", - "Title": "Screen reader support", + "Title": "Screen Reader Support", "ImagePath": "ms-appx:///Assets/ControlImages/AppBarSeparator.png", "ImageIconPath": "ms-appx:///Assets/ControlIcons/AppBarSeparatorIcon.png", "HideSourceCodeAndRelatedControls": true, @@ -534,7 +545,7 @@ "ApiNamespace": "Microsoft.UI.Xaml.Controls", "Subtitle": "A control that presents a collection of items using various layouts.", "ImagePath": "ms-appx:///Assets/ControlImages/ItemsView.png", - "ImageIconPath": "ms-appx:///Assets/ControlIcons/ItemsViewIcon.png", + "ImageIconPath": "ms-appx:///Assets/ControlIcons/DefaultIcon.png", "Description": "The ItemsView lets you show a collection of items using scrollable & swappable layouts.", "Content": "

ItemsView can contain a collection of items of any type. To populate the view, set the ItemsSource property to a data source.

Set a Layout to define how the items are laid out.

Set an ItemTemplate to define the look of individual items.

Look at the ItemsViewPage.xaml file in Visual Studio to see the full code for this page.

", "IsNew": true, @@ -1428,8 +1439,8 @@ "Title": "AnnotatedScrollBar", "ApiNamespace": "Microsoft.UI.Xaml.Controls", "Subtitle": "A control that extends a regular vertical scrollbar's functionality for an easy navigation through large collections.", - "ImagePath": "ms-appx:///Assets/ControlImages/AnnotatedScrollBar.png", - "ImageIconPath": "ms-appx:///Assets/ControlIcons/AnnotatedScrollBarIcon.png", + "ImagePath": "ms-appx:///Assets/ControlImages/Placeholder.png", + "ImageIconPath": "ms-appx:///Assets/ControlIcons/DefaultIcon.png", "Description": "The AnnotatedScrollBar lets you navigate through a large collection of items via a clickable rail with labels which act as markers.", "Content": "

AnnotatedScrollBar can be connected to a scrollable container, like a ScrollView, via its ScrollController property.

Populate the Labels property with special values that act as markers.

Set the LabelTemplate and DetailLabelTemplate data templates to define the labels' and more granular tooltips' looks.

Look at the AnnotatedScrollBarPage.xaml file in Visual Studio to see the full code for this page.

", "IsNew": true, @@ -1475,7 +1486,7 @@ "ApiNamespace": "Microsoft.UI.Xaml.Controls", "Subtitle": "A container control that lets the user pan and zoom its content.", "ImagePath": "ms-appx:///Assets/ControlImages/ScrollView.png", - "ImageIconPath": "ms-appx:///Assets/ControlIcons/ScrollViewIcon.png", + "ImageIconPath": "ms-appx:///Assets/ControlIcons/DefaultIcon.png", "Description": "A ScrollView lets a user scroll, pan, and zoom to see content that's larger than the viewable area. The ItemsView has a ScrollView built into its control template to provide automatic scrolling.", "Content": "

Look at the ScrollViewPage.xaml file in Visual Studio to see the full code for this page.

", "IsNew": true, @@ -2011,6 +2022,24 @@ } ] }, + { + "UniqueId": "CaptureElementPreview", + "Title": "Capture Element / Camera Preview", + "Subtitle": "A sample for doing a camera preview.", + "ImagePath": "ms-appx:///Assets/ControlImages/MediaPlayerElement.png", + "ImageIconPath": "ms-appx:///Assets/ControlIcons/MediaElementIcon.png", + "Description": "You can use a MediaPlayerElement control to show a camera preview with a MediaCapture object.", + "IsNew": true, + "Docs": [ + { + "Title": "MediaCapture - API", + "Uri": "https://learn.microsoft.com/uwp/api/windows.media.capture.mediacapture" + } + ], + "RelatedControls": [ + "MediaPlayerElement" + ] + }, { "UniqueId": "Image", "Title": "Image", @@ -2711,15 +2740,11 @@ }, { "Title": "Composition Animation - API", - "Uri": "https://learn.microsoft.com/windows/uwp/composition/composition-animation" + "Uri": "https://learn.microsoft.com/windows/apps/windows-app-sdk/composition" }, { "Title": "Guidelines - Xaml Property Animations", "Uri": "https://learn.microsoft.com/windows/apps/design/motion/xaml-property-animations" - }, - { - "Title": "Using the Visual Layer with XAML", - "Uri": "https://learn.microsoft.com/windows/uwp/composition/using-the-visual-layer-with-xaml" } ], "RelatedControls": [ @@ -2814,7 +2839,7 @@ "Subtitle": "An example showing a custom UIElement used as the titlebar for the app's window.", "ImagePath": "ms-appx:///Assets/ControlImages/TitleBar.png", "ImageIconPath": "ms-appx:///Assets/ControlIcons/DefaultIcon.png", - "Description": "This sample shows how to use a custom UIElement as titlebar for app's window.", + "Description": "This sample shows how to use a custom titlebar for the app's window. There are 2 ways of doing it: using default titlebar and setting an UIElement as a custom titlebar.", "Content": "

Look at the TitleBarPage.xaml file in Visual Studio to see the full code for this page.

", "IsUpdated": true, "Docs": [ diff --git a/WinUIGallery/Directory.Build.props b/WinUIGallery/Directory.Build.props index 39faf6040..73bd14dbf 100644 --- a/WinUIGallery/Directory.Build.props +++ b/WinUIGallery/Directory.Build.props @@ -3,6 +3,8 @@ true + + true diff --git a/WinUIGallery/Directory.Build.targets b/WinUIGallery/Directory.Build.targets index 02e07802b..f2130e3c0 100644 --- a/WinUIGallery/Directory.Build.targets +++ b/WinUIGallery/Directory.Build.targets @@ -5,5 +5,7 @@ WinUIGallery.Desktop - + + + \ No newline at end of file diff --git a/WinUIGallery/Helper/NavigationHelper.cs b/WinUIGallery/Helper/NavigationHelper.cs index a35735ae7..d4565c98e 100644 --- a/WinUIGallery/Helper/NavigationHelper.cs +++ b/WinUIGallery/Helper/NavigationHelper.cs @@ -215,17 +215,6 @@ private bool TryGoBack() return navigated; } - private bool TryGoForward() - { - bool navigated = false; - if (this.Frame.CanGoForward) - { - this.Frame.GoForward(); - navigated = true; - } - return navigated; - } - private void UpdateBackButton() { if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 6)) @@ -234,75 +223,6 @@ private void UpdateBackButton() this.CurrentNavView.IsBackEnabled = this.Frame.CanGoBack ? true : false; } } - - // /// - // /// Invoked on every keystroke, including system keys such as Alt key combinations. - // /// Used to detect keyboard navigation between pages even when the page itself - // /// doesn't have focus. - // /// - // /// Instance that triggered the event. - // /// Event data describing the conditions that led to the event. - // private void CoreDispatcher_AcceleratorKeyActivated(DispatcherQueue sender, - // AcceleratorKeyEventArgs e) - // { - // var virtualKey = e.VirtualKey; - - // // Only investigate further when Left, Right, or the dedicated Previous or Next keys - // // are pressed - // if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown || - // e.EventType == CoreAcceleratorKeyEventType.KeyDown) && - // (virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right || - // (int)virtualKey == 166 || (int)virtualKey == 167)) - // { - // var downState = CoreVirtualKeyStates.Down; - // bool menuKey = (Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Menu) & downState) == downState; - // bool controlKey = (Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control) & downState) == downState; - // bool shiftKey = (Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Shift) & downState) == downState; - // bool noModifiers = !menuKey && !controlKey && !shiftKey; - // bool onlyAlt = menuKey && !controlKey && !shiftKey; - - // if (((int)virtualKey == 166 && noModifiers) || - // (virtualKey == VirtualKey.Left && onlyAlt)) - // { - // // When the previous key or Alt+Left are pressed navigate back - // e.Handled = TryGoBack(); - // } - // else if (((int)virtualKey == 167 && noModifiers) || - // (virtualKey == VirtualKey.Right && onlyAlt)) - // { - // // When the next key or Alt+Right are pressed navigate forward - // e.Handled = TryGoForward(); - // } - // } - // } - - // /// - // /// Invoked on every mouse click, touch screen tap, or equivalent interaction. - // /// Used to detect browser-style next and previous mouse button clicks - // /// to navigate between pages. - // /// - // /// Instance that triggered the event. - // /// Event data describing the conditions that led to the event. - // private void CoreWindow_PointerPressed(CoreWindow sender, - // PointerEventArgs e) - // { - // var properties = e.CurrentPoint.Properties; - - // // Ignore button chords with the left, right, and middle buttons - // if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed || - // properties.IsMiddleButtonPressed) - // return; - - // // If back or forward are pressed (but not both) navigate appropriately - // bool backPressed = properties.IsXButton1Pressed; - // bool forwardPressed = properties.IsXButton2Pressed; - // if (backPressed ^ forwardPressed) - // { - // e.Handled = true; - // if (backPressed) this.TryGoBack(); - // if (forwardPressed) this.TryGoForward(); - // } - // } } /// diff --git a/WinUIGallery/Helper/ThemeHelper.cs b/WinUIGallery/Helper/ThemeHelper.cs index cb2f6e5ea..9a6df40cf 100644 --- a/WinUIGallery/Helper/ThemeHelper.cs +++ b/WinUIGallery/Helper/ThemeHelper.cs @@ -13,7 +13,6 @@ public static class ThemeHelper { private const string SelectedAppThemeKey = "SelectedAppTheme"; - private static Window CurrentApplicationWindow; /// /// Gets the current actual theme of the app based on the requested theme of the /// root element, or if that value is Default, the requested theme of the Application. @@ -75,8 +74,6 @@ public static void Initialize() { if (NativeHelper.IsAppPackaged) { - // Save reference as this might be null when the user is in another app - CurrentApplicationWindow = App.StartupWindow; string savedTheme = ApplicationData.Current.LocalSettings.Values[SelectedAppThemeKey]?.ToString(); if (savedTheme != null) diff --git a/WinUIGallery/Helper/TitleBarHelper.cs b/WinUIGallery/Helper/TitleBarHelper.cs index 2217b5a88..81a05ca01 100644 --- a/WinUIGallery/Helper/TitleBarHelper.cs +++ b/WinUIGallery/Helper/TitleBarHelper.cs @@ -19,30 +19,13 @@ namespace WinUIGallery.DesktopWap.Helper { + internal class TitleBarHelper { - - private static void triggerTitleBarRepaint(Window window) - { - // to trigger repaint tracking task id 38044406 - var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(window); - var activeWindow = AppUIBasics.Win32.GetActiveWindow(); - if (hwnd == activeWindow) - { - AppUIBasics.Win32.SendMessage(hwnd, AppUIBasics.Win32.WM_ACTIVATE, AppUIBasics.Win32.WA_INACTIVE, IntPtr.Zero); - AppUIBasics.Win32.SendMessage(hwnd, AppUIBasics.Win32.WM_ACTIVATE, AppUIBasics.Win32.WA_ACTIVE, IntPtr.Zero); - } - else - { - AppUIBasics.Win32.SendMessage(hwnd, AppUIBasics.Win32.WM_ACTIVATE, AppUIBasics.Win32.WA_ACTIVE, IntPtr.Zero); - AppUIBasics.Win32.SendMessage(hwnd, AppUIBasics.Win32.WM_ACTIVATE, AppUIBasics.Win32.WA_INACTIVE, IntPtr.Zero); - } - - } - + // workaround as Appwindow titlebar doesn't update caption button colors correctly when changed while app is running + // https://task.ms/44172495 public static Windows.UI.Color ApplySystemThemeToCaptionButtons(Window window) { - var res = Application.Current.Resources; var frame = (Application.Current as AppUIBasics.App).GetRootFrame() as FrameworkElement; Windows.UI.Color color; if (frame.ActualTheme == ElementTheme.Dark) @@ -61,7 +44,7 @@ public static void SetCaptionButtonColors(Window window, Windows.UI.Color color) { var res = Application.Current.Resources; res["WindowCaptionForeground"] = color; - triggerTitleBarRepaint(window); + window.AppWindow.TitleBar.ButtonForegroundColor = color; } } } diff --git a/WinUIGallery/Helper/WindowHelper.cs b/WinUIGallery/Helper/WindowHelper.cs index 5398cb12e..5bb134e30 100644 --- a/WinUIGallery/Helper/WindowHelper.cs +++ b/WinUIGallery/Helper/WindowHelper.cs @@ -66,6 +66,21 @@ static public Window GetWindowForElement(UIElement element) } return null; } + // get dpi for an element + static public double GetRasterizationScaleForElement(UIElement element) + { + if (element.XamlRoot != null) + { + foreach (Window window in _activeWindows) + { + if (element.XamlRoot == window.Content.XamlRoot) + { + return element.XamlRoot.RasterizationScale; + } + } + } + return 0.0; + } static public List ActiveWindows { get { return _activeWindows; }} diff --git a/WinUIGallery/NewControlsPage.xaml b/WinUIGallery/HomePage.xaml similarity index 99% rename from WinUIGallery/NewControlsPage.xaml rename to WinUIGallery/HomePage.xaml index 191f39ea4..89c0d08de 100644 --- a/WinUIGallery/NewControlsPage.xaml +++ b/WinUIGallery/HomePage.xaml @@ -10,7 +10,7 @@ //********************************************************* --> 0) { return errorString; } AddLog("After WaitForRootVisualReset"); @@ -228,6 +211,7 @@ private string WaitInternal(out string logMessage) WaitForIdleDispatcher(); AddLog("After WaitForIdleDispatcher"); + bool hadAnimations; // At this point, we know that the UI thread is idle - now we need to make sure // that XAML isn't animating anything. // TODO 27870237: Remove this #if once BuildTreeServiceDrained is properly signaled in WinUI desktop apps. @@ -246,6 +230,7 @@ private string WaitInternal(out string logMessage) hadAnimations = false; } + bool hadDeferredAnimationOperations; errorString = WaitForDeferredAnimationOperationsComplete(out hadDeferredAnimationOperations); if (errorString.Length > 0) { return errorString; } AddLog("After WaitForDeferredAnimationOperationsComplete"); @@ -324,70 +309,6 @@ void WaitForIdleDispatcher() shouldContinueEvent.WaitOne(s_defaultWaitForEventMs); } - string WaitForBuildTreeServiceWork(out bool hadBuildTreeWork) - { - hadBuildTreeWork = false; - bool hasBuildTreeWork = true; - - // We want to avoid an infinite loop, so we'll iterate 20 times before concluding that - // we probably are never going to become idle. - int waitCount = 20; - - while (hasBuildTreeWork && waitCount-- > 0) - { - if (!NativeMethods.ResetEvent(m_buildTreeServiceDrainedHandle.NativeHandle)) - { - return "Failed to reset BuildTreeServiceDrained handle."; - } - - AutoResetEvent layoutUpdatedEvent = new AutoResetEvent(false); - - m_dispatcherQueue.TryEnqueue( - DispatcherQueuePriority.Normal, - new DispatcherQueueHandler(() => - { - foreach (Window window in WindowHelper.ActiveWindows) - { - if (window.Content != null) - { - window.Content.UpdateLayout(); - } - } - - layoutUpdatedEvent.Set(); - })); - - layoutUpdatedEvent.WaitOne(s_defaultWaitForEventMs); - - // This will be signaled if and only if Jupiter plans to at some point in the near - // future set the BuildTreeServiceDrained event. - uint waitResult = NativeMethods.WaitForSingleObject(m_hasBuildTreeWorksHandle.NativeHandle, 0); - - if (waitResult != NativeMethods.WAIT_OBJECT_0 && waitResult != NativeMethods.WAIT_TIMEOUT) - { - return "HasBuildTreeWork handle wait returned an invalid value."; - } - - hasBuildTreeWork = (waitResult == NativeMethods.WAIT_OBJECT_0); - AddLog("HasBuildTreeWork? " + hasBuildTreeWork); - - if (hasBuildTreeWork) - { - AddLog("Waiting for BuildTreeService to finish..."); - waitResult = NativeMethods.WaitForSingleObject(m_buildTreeServiceDrainedHandle.NativeHandle, 10000); - - if (waitResult != NativeMethods.WAIT_OBJECT_0 && waitResult != NativeMethods.WAIT_TIMEOUT) - { - return "Wait for build tree service failed"; - } - AddLog("BuildTreeService drained"); - } - } - - hadBuildTreeWork = hasBuildTreeWork; - return string.Empty; - } - string WaitForAnimationsComplete(out bool hadAnimations) { hadAnimations = false; @@ -473,31 +394,6 @@ string WaitForDeferredAnimationOperationsComplete(out bool hadDeferredAnimationO return string.Empty; } - private void SynchronouslyTickUIThread(uint ticks) - { - for (uint i = 0; i < ticks; i++) - { - AutoResetEvent tickCompleteEvent = new AutoResetEvent(false); - - m_dispatcherQueue.TryEnqueue( - DispatcherQueuePriority.Normal, - new DispatcherQueueHandler(() => - { - EventHandler renderingHandler = null; - - renderingHandler = (object sender, object args) => - { - CompositionTarget.Rendering -= renderingHandler; - tickCompleteEvent.Set(); - }; - - CompositionTarget.Rendering += renderingHandler; - })); - - tickCompleteEvent.WaitOne(s_defaultWaitForEventMs); - } - } - private bool IsRS2OrHigher() { if (!m_isRS2OrHigherInitialized) @@ -596,4 +492,4 @@ public enum SyncObjectAccess : uint TIMER_MODIFY_STATE = 0x00000002, TIMER_QUERY_STATE = 0x00000001 } -} \ No newline at end of file +} diff --git a/WinUIGallery/ItemsPageBase.cs b/WinUIGallery/ItemsPageBase.cs index fea644e78..9ff58503f 100644 --- a/WinUIGallery/ItemsPageBase.cs +++ b/WinUIGallery/ItemsPageBase.cs @@ -59,7 +59,6 @@ protected void OnItemGridViewContainerContentChanging(ListViewBase sender, Conta protected void OnItemGridViewItemClick(object sender, ItemClickEventArgs e) { - var gridView = (GridView)sender; var item = (ControlInfoDataItem)e.ClickedItem; _itemId = item.UniqueId; diff --git a/WinUIGallery/Navigation/NavigationRootPage.xaml b/WinUIGallery/Navigation/NavigationRootPage.xaml index 7e9b30071..9aa820534 100644 --- a/WinUIGallery/Navigation/NavigationRootPage.xaml +++ b/WinUIGallery/Navigation/NavigationRootPage.xaml @@ -67,6 +67,7 @@ VerticalAlignment="Center" Style="{StaticResource CaptionTextBlockStyle}" Text="{x:Bind AppTitleText}" /> + @@ -186,29 +187,31 @@ Navigating="OnRootFrameNavigating" /> - + - + - + diff --git a/WinUIGallery/Navigation/NavigationRootPage.xaml.cs b/WinUIGallery/Navigation/NavigationRootPage.xaml.cs index 15d7dcd0c..98c09932d 100644 --- a/WinUIGallery/Navigation/NavigationRootPage.xaml.cs +++ b/WinUIGallery/Navigation/NavigationRootPage.xaml.cs @@ -21,6 +21,7 @@ using Microsoft.UI.Xaml.Automation; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Navigation; using Windows.Foundation; using Windows.System.Profile; @@ -210,6 +211,7 @@ private void AddNavigationMenuItems() itemGroup.ContextFlyout = new MenuFlyout() { Items = { groupMenuFlyoutItem } }; AutomationProperties.SetName(itemGroup, group.Title); + AutomationProperties.SetAutomationId(itemGroup, group.UniqueId); foreach (var item in group.Items) { @@ -221,12 +223,13 @@ private void AddNavigationMenuItems() itemGroup.MenuItems.Add(itemInGroup); AutomationProperties.SetName(itemInGroup, item.Title); + AutomationProperties.SetAutomationId(itemInGroup, item.UniqueId); } NavigationViewControl.MenuItems.Add(itemGroup); } - NewControlsItem.Loaded += OnNewControlsMenuItemLoaded; + Home.Loaded += OnHomeMenuItemLoaded; } private void OnMenuFlyoutItemClick(object sender, RoutedEventArgs e) @@ -264,7 +267,7 @@ private void SetDeviceFamily() DeviceFamily = parsedDeviceType; } - private void OnNewControlsMenuItemLoaded(object sender, RoutedEventArgs e) + private void OnHomeMenuItemLoaded(object sender, RoutedEventArgs e) { if ( NavigationViewControl.DisplayMode == NavigationViewDisplayMode.Expanded) { @@ -276,6 +279,17 @@ private void OnNavigationViewControlLoaded(object sender, RoutedEventArgs e) { // Delay necessary to ensure NavigationView visual state can match navigation Task.Delay(500).ContinueWith(_ => this.NavigationViewLoaded?.Invoke(), TaskScheduler.FromCurrentSynchronizationContext()); + + var navigationView = sender as NavigationView; + navigationView.RegisterPropertyChangedCallback(NavigationView.IsPaneOpenProperty, OnIsPaneOpenChanged); + } + + private void OnIsPaneOpenChanged(DependencyObject sender, DependencyProperty dp) + { + var navigationView = sender as NavigationView; + var announcementText = navigationView.IsPaneOpen ? "Navigation Pane Opened" : "Navigation Pane Closed"; + + UIHelper.AnnounceActionForAccessibility(navigationView, announcementText, "NavigationViewPaneIsOpenChangeNotificationId"); } private void OnNavigationViewSelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) @@ -297,11 +311,11 @@ private void OnNavigationViewSelectionChanged(NavigationView sender, NavigationV Navigate(typeof(AllControlsPage)); } } - else if (selectedItem == NewControlsItem) + else if (selectedItem == Home) { - if (rootFrame.CurrentSourcePageType != typeof(NewControlsPage)) + if (rootFrame.CurrentSourcePageType != typeof(HomePage)) { - Navigate(typeof(NewControlsPage)); + Navigate(typeof(HomePage)); } } else if (selectedItem == DesignGuidanceItem || selectedItem == AccessibilityItem) diff --git a/WinUIGallery/Package.Dev.appxmanifest b/WinUIGallery/Package.Dev.appxmanifest index 376fb3ffd..8570c1bae 100644 --- a/WinUIGallery/Package.Dev.appxmanifest +++ b/WinUIGallery/Package.Dev.appxmanifest @@ -7,7 +7,7 @@ xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp uap3"> - + WinUI 3 Gallery Dev diff --git a/WinUIGallery/Package.appxmanifest b/WinUIGallery/Package.appxmanifest index 0f54f79d7..a4b84cf71 100644 --- a/WinUIGallery/Package.appxmanifest +++ b/WinUIGallery/Package.appxmanifest @@ -7,7 +7,7 @@ xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp uap3"> - + WinUI 3 Gallery diff --git a/WinUIGallery/Properties/AssemblyInfo.cs b/WinUIGallery/Properties/AssemblyInfo.cs index 378eef0fa..99bab15c3 100644 --- a/WinUIGallery/Properties/AssemblyInfo.cs +++ b/WinUIGallery/Properties/AssemblyInfo.cs @@ -25,6 +25,6 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] // Note: package version and assembly version must be kept in sync -[assembly: AssemblyVersion("2.1.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] [assembly: ComVisible(false)] diff --git a/WinUIGallery/Properties/PublishProfiles/win10-arm64-unpackaged.pubxml b/WinUIGallery/Properties/PublishProfiles/win10-arm64-unpackaged.pubxml index f7ce80a46..234387866 100644 --- a/WinUIGallery/Properties/PublishProfiles/win10-arm64-unpackaged.pubxml +++ b/WinUIGallery/Properties/PublishProfiles/win10-arm64-unpackaged.pubxml @@ -7,10 +7,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. FileSystem ARM64 win10-arm64 - true + + True False False - $(Optimized) + False $(Optimized) + + partial \ No newline at end of file diff --git a/WinUIGallery/Properties/PublishProfiles/win10-arm64.pubxml b/WinUIGallery/Properties/PublishProfiles/win10-arm64.pubxml index fc9dd1110..7777f0dc8 100644 --- a/WinUIGallery/Properties/PublishProfiles/win10-arm64.pubxml +++ b/WinUIGallery/Properties/PublishProfiles/win10-arm64.pubxml @@ -7,10 +7,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. FileSystem ARM64 win10-arm64 - true + + True False True - $(Optimized) + False $(Optimized) + + partial \ No newline at end of file diff --git a/WinUIGallery/Properties/PublishProfiles/win10-x64-unpackaged.pubxml b/WinUIGallery/Properties/PublishProfiles/win10-x64-unpackaged.pubxml index f414c5b0d..0b74be333 100644 --- a/WinUIGallery/Properties/PublishProfiles/win10-x64-unpackaged.pubxml +++ b/WinUIGallery/Properties/PublishProfiles/win10-x64-unpackaged.pubxml @@ -7,10 +7,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. FileSystem x64 win10-x64 - true + + True False False - $(Optimized) + False $(Optimized) + + partial \ No newline at end of file diff --git a/WinUIGallery/Properties/PublishProfiles/win10-x64.pubxml b/WinUIGallery/Properties/PublishProfiles/win10-x64.pubxml index 157e4475f..0ba94cf14 100644 --- a/WinUIGallery/Properties/PublishProfiles/win10-x64.pubxml +++ b/WinUIGallery/Properties/PublishProfiles/win10-x64.pubxml @@ -7,10 +7,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. FileSystem x64 win10-x64 - true + + True False True - $(Optimized) + False $(Optimized) + + partial \ No newline at end of file diff --git a/WinUIGallery/Properties/PublishProfiles/win10-x86-unpackaged.pubxml b/WinUIGallery/Properties/PublishProfiles/win10-x86-unpackaged.pubxml index da5cdcfb8..2bda3fa70 100644 --- a/WinUIGallery/Properties/PublishProfiles/win10-x86-unpackaged.pubxml +++ b/WinUIGallery/Properties/PublishProfiles/win10-x86-unpackaged.pubxml @@ -7,10 +7,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. FileSystem x86 win10-x86 - true + + True False False - $(Optimized) + False $(Optimized) + + partial \ No newline at end of file diff --git a/WinUIGallery/Properties/PublishProfiles/win10-x86.pubxml b/WinUIGallery/Properties/PublishProfiles/win10-x86.pubxml index 847c4c474..8319695f4 100644 --- a/WinUIGallery/Properties/PublishProfiles/win10-x86.pubxml +++ b/WinUIGallery/Properties/PublishProfiles/win10-x86.pubxml @@ -7,10 +7,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. FileSystem x86 win10-x86 - true + + True False True - $(Optimized) + False $(Optimized) + + partial \ No newline at end of file diff --git a/WinUIGallery/SamplePages/SampleSystemBackdropsWindow.xaml.cs b/WinUIGallery/SamplePages/SampleSystemBackdropsWindow.xaml.cs index 487c4049c..66148b84f 100644 --- a/WinUIGallery/SamplePages/SampleSystemBackdropsWindow.xaml.cs +++ b/WinUIGallery/SamplePages/SampleSystemBackdropsWindow.xaml.cs @@ -64,7 +64,8 @@ public enum BackdropType { Mica, MicaAlt, - DesktopAcrylic, + DesktopAcrylicBase, + DesktopAcrylicThin, DefaultColor, } @@ -112,7 +113,7 @@ public void SetBackdrop(BackdropType type) else { // Mica isn't supported. Try Acrylic. - type = BackdropType.DesktopAcrylic; + type = BackdropType.DesktopAcrylicBase; tbChangeStatus.Text += " Mica isn't supported. Trying Acrylic."; } } @@ -126,23 +127,37 @@ public void SetBackdrop(BackdropType type) else { // MicaAlt isn't supported. Try Acrylic. - type = BackdropType.DesktopAcrylic; + type = BackdropType.DesktopAcrylicBase; tbChangeStatus.Text += " MicaAlt isn't supported. Trying Acrylic."; } } - if (type == BackdropType.DesktopAcrylic) + if (type == BackdropType.DesktopAcrylicBase) { - if (TrySetAcrylicBackdrop()) + if (TrySetAcrylicBackdrop(false)) { - tbCurrentBackdrop.Text = "Custom Acrylic"; + tbCurrentBackdrop.Text = "Custom Acrylic (Base)"; m_currentBackdrop = type; } else { // Acrylic isn't supported, so take the next option, which is DefaultColor, which is already set. - tbChangeStatus.Text += " Acrylic isn't supported. Switching to default color."; + tbChangeStatus.Text += " Acrylic Base isn't supported. Switching to default color."; } } + if (type == BackdropType.DesktopAcrylicThin) + { + if (TrySetAcrylicBackdrop(true)) + { + tbCurrentBackdrop.Text = "Custom Acrylic (Thin)"; + m_currentBackdrop = type; + } + else + { + // Acrylic isn't supported, so take the next option, which is DefaultColor, which is already set. + tbChangeStatus.Text += " Acrylic Thin isn't supported. Switching to default color."; + } + } + // announce visual change to automation UIHelper.AnnounceActionForAccessibility(btnChangeBackdrop, $"Background changed to {tbCurrentBackdrop.Text}", "BackgroundChangedNotificationActivityId"); } @@ -175,7 +190,7 @@ bool TrySetMicaBackdrop(bool useMicaAlt) return false; // Mica is not supported on this system. } - bool TrySetAcrylicBackdrop() + bool TrySetAcrylicBackdrop(bool useAcrylicThin) { if (Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController.IsSupported()) { @@ -191,6 +206,8 @@ bool TrySetAcrylicBackdrop() m_acrylicController = new Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController(); + m_acrylicController.Kind = useAcrylicThin ? Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicKind.Thin : Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicKind.Base; + // Enable the system backdrop. // Note: Be sure to have "using WinRT;" to support the Window.As<...>() call. m_acrylicController.AddSystemBackdropTarget(this.As()); @@ -248,8 +265,9 @@ void ChangeBackdropButton_Click(object sender, RoutedEventArgs e) switch (m_currentBackdrop) { case BackdropType.Mica: newType = BackdropType.MicaAlt; break; - case BackdropType.MicaAlt: newType = BackdropType.DesktopAcrylic; break; - case BackdropType.DesktopAcrylic: newType = BackdropType.DefaultColor; break; + case BackdropType.MicaAlt: newType = BackdropType.DesktopAcrylicBase; break; + case BackdropType.DesktopAcrylicBase: newType = BackdropType.DesktopAcrylicThin; break; + case BackdropType.DesktopAcrylicThin: newType = BackdropType.DefaultColor; break; default: case BackdropType.DefaultColor: newType = BackdropType.Mica; break; } diff --git a/WinUIGallery/Strings/en-US/Resources.resw b/WinUIGallery/Strings/en-US/Resources.resw index 12ff01ae8..e7a53bf84 100644 --- a/WinUIGallery/Strings/en-US/Resources.resw +++ b/WinUIGallery/Strings/en-US/Resources.resw @@ -223,10 +223,10 @@ Enter ZIP code - + What's New - + What's New \ No newline at end of file diff --git a/WinUIGallery/TabViewPages/TabViewWindowingSamplePage.xaml.cs b/WinUIGallery/TabViewPages/TabViewWindowingSamplePage.xaml.cs index a473be8bf..9d53b846f 100644 --- a/WinUIGallery/TabViewPages/TabViewWindowingSamplePage.xaml.cs +++ b/WinUIGallery/TabViewPages/TabViewWindowingSamplePage.xaml.cs @@ -1,177 +1,152 @@ -using System; -using Windows.ApplicationModel.Core; -using Windows.ApplicationModel.DataTransfer; -using Windows.Foundation.Metadata; -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Controls.Primitives; -using Microsoft.UI.Xaml.Hosting; -using Microsoft.UI.Xaml.Navigation; -using Microsoft.UI.Windowing; -using AppUIBasics.Helper; +using System; +using Windows.ApplicationModel.Core; +using Windows.ApplicationModel.DataTransfer; +using Windows.Foundation.Metadata; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Hosting; +using Microsoft.UI.Xaml.Navigation; +using Microsoft.UI.Windowing; +using AppUIBasics.Helper; using System.Threading; using Microsoft.UI.Dispatching; using System.Threading.Tasks; using Windows.System; using DispatcherQueueHandler = Microsoft.UI.Dispatching.DispatcherQueueHandler; -namespace AppUIBasics.TabViewPages -{ - public sealed partial class TabViewWindowingSamplePage : Page - { - private const string DataIdentifier = "MyTabItem"; - public TabViewWindowingSamplePage() - { - this.InitializeComponent(); - - Tabs.TabItemsChanged += Tabs_TabItemsChanged; - - Loaded += TabViewWindowingSamplePage_Loaded; - } - - private void TabViewWindowingSamplePage_Loaded(object sender, RoutedEventArgs e) - { - var currentWindow = WindowHelper.GetWindowForElement(this); - currentWindow.ExtendsContentIntoTitleBar = true; - currentWindow.SetTitleBar(CustomDragRegion); - CustomDragRegion.MinWidth = 188; - } - - private void Tabs_TabItemsChanged(TabView sender, Windows.Foundation.Collections.IVectorChangedEventArgs args) - { - // If there are no more tabs, close the window. - if (sender.TabItems.Count == 0) - { - WindowHelper.GetWindowForElement(this).Close(); - } - // If there is only one tab left, disable dragging and reordering of Tabs. - else if (sender.TabItems.Count == 1) - { - sender.CanReorderTabs = false; - sender.CanDragTabs = false; - } - else - { - sender.CanReorderTabs = true; - sender.CanDragTabs = true; - } - } - - protected override void OnNavigatedTo(NavigationEventArgs e) - { - base.OnNavigatedTo(e); - - SetupWindow(); - } - - void SetupWindow() - { - - // Main Window -- add some default items - for (int i = 0; i < 3; i++) - { - Tabs.TabItems.Add(new TabViewItem() { IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Placeholder }, Header = $"Item {i}", Content = new MyTabContentControl() { DataContext = $"Page {i}" } }); - } - - Tabs.SelectedIndex = 0; - } - - private void CoreTitleBar_LayoutMetricsChanged(CoreApplicationViewTitleBar sender, object args) - { - // To ensure that the tabs in the titlebar are not occluded by shell - // content, we must ensure that we account for left and right overlays. - // In LTR layouts, the right inset includes the caption buttons and the - // drag region, which is flipped in RTL. - - // The SystemOverlayLeftInset and SystemOverlayRightInset values are - // in terms of physical left and right. Therefore, we need to flip - // then when our flow direction is RTL. - if (FlowDirection == FlowDirection.LeftToRight) - { - CustomDragRegion.MinWidth = sender.SystemOverlayRightInset; - ShellTitleBarInset.MinWidth = sender.SystemOverlayLeftInset; - } - else - { - CustomDragRegion.MinWidth = sender.SystemOverlayLeftInset; - ShellTitleBarInset.MinWidth = sender.SystemOverlayRightInset; - } - - // Ensure that the height of the custom regions are the same as the titlebar. - CustomDragRegion.Height = ShellTitleBarInset.Height = sender.Height; - } - - public void AddTabToTabs(TabViewItem tab) - { - Tabs.TabItems.Add(tab); - } - - // Create a new Window once the Tab is dragged outside. - private void Tabs_TabDroppedOutside(TabView sender, TabViewTabDroppedOutsideEventArgs args) - { - var newPage = new TabViewWindowingSamplePage(); - - Tabs.TabItems.Remove(args.Tab); - newPage.AddTabToTabs(args.Tab); - - var newWindow = WindowHelper.CreateWindow(); - newWindow.ExtendsContentIntoTitleBar = true; - newWindow.Content = newPage; - - newWindow.Activate(); - } - - private void Tabs_TabDragStarting(TabView sender, TabViewTabDragStartingEventArgs args) - { - // We can only drag one tab at a time, so grab the first one... - var firstItem = args.Tab; - - // ... set the drag data to the tab... - args.Data.Properties.Add(DataIdentifier, firstItem); - - // ... and indicate that we can move it - args.Data.RequestedOperation = DataPackageOperation.Move; - } - - private async void Tabs_TabStripDrop(object sender, DragEventArgs e) - { - // This event is called when we're dragging between different TabViews - // It is responsible for handling the drop of the item into the second TabView - - if (e.DataView.Properties.TryGetValue(DataIdentifier, out object obj)) - { - // Ensure that the obj property is set before continuing. - if (obj == null) - { - return; - } - - var destinationTabView = sender as TabView; - var destinationItems = destinationTabView.TabItems; - - if (destinationItems != null) - { - // First we need to get the position in the List to drop to - var index = -1; - - // Determine which items in the list our pointer is between. - for (int i = 0; i < destinationTabView.TabItems.Count; i++) - { - var item = destinationTabView.ContainerFromIndex(i) as TabViewItem; - - if (e.GetPosition(item).X - item.ActualWidth < 0) - { - index = i; - break; - } +namespace AppUIBasics.TabViewPages +{ + public sealed partial class TabViewWindowingSamplePage : Page + { + private const string DataIdentifier = "MyTabItem"; + public TabViewWindowingSamplePage() + { + this.InitializeComponent(); + + Tabs.TabItemsChanged += Tabs_TabItemsChanged; + + Loaded += TabViewWindowingSamplePage_Loaded; + } + + private void TabViewWindowingSamplePage_Loaded(object sender, RoutedEventArgs e) + { + var currentWindow = WindowHelper.GetWindowForElement(this); + currentWindow.ExtendsContentIntoTitleBar = true; + currentWindow.SetTitleBar(CustomDragRegion); + CustomDragRegion.MinWidth = 188; + } + + private void Tabs_TabItemsChanged(TabView sender, Windows.Foundation.Collections.IVectorChangedEventArgs args) + { + // If there are no more tabs, close the window. + if (sender.TabItems.Count == 0) + { + WindowHelper.GetWindowForElement(this).Close(); + } + // If there is only one tab left, disable dragging and reordering of Tabs. + else if (sender.TabItems.Count == 1) + { + sender.CanReorderTabs = false; + sender.CanDragTabs = false; + } + else + { + sender.CanReorderTabs = true; + sender.CanDragTabs = true; + } + } + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + + SetupWindow(); + } + + void SetupWindow() + { + + // Main Window -- add some default items + for (int i = 0; i < 3; i++) + { + Tabs.TabItems.Add(new TabViewItem() { IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Placeholder }, Header = $"Item {i}", Content = new MyTabContentControl() { DataContext = $"Page {i}" } }); + } + + Tabs.SelectedIndex = 0; + } + + public void AddTabToTabs(TabViewItem tab) + { + Tabs.TabItems.Add(tab); + } + + // Create a new Window once the Tab is dragged outside. + private void Tabs_TabDroppedOutside(TabView sender, TabViewTabDroppedOutsideEventArgs args) + { + var newPage = new TabViewWindowingSamplePage(); + + Tabs.TabItems.Remove(args.Tab); + newPage.AddTabToTabs(args.Tab); + + var newWindow = WindowHelper.CreateWindow(); + newWindow.ExtendsContentIntoTitleBar = true; + newWindow.Content = newPage; + + newWindow.Activate(); + } + + private void Tabs_TabDragStarting(TabView sender, TabViewTabDragStartingEventArgs args) + { + // We can only drag one tab at a time, so grab the first one... + var firstItem = args.Tab; + + // ... set the drag data to the tab... + args.Data.Properties.Add(DataIdentifier, firstItem); + + // ... and indicate that we can move it + args.Data.RequestedOperation = DataPackageOperation.Move; + } + + private async void Tabs_TabStripDrop(object sender, DragEventArgs e) + { + // This event is called when we're dragging between different TabViews + // It is responsible for handling the drop of the item into the second TabView + + if (e.DataView.Properties.TryGetValue(DataIdentifier, out object obj)) + { + // Ensure that the obj property is set before continuing. + if (obj == null) + { + return; + } + + var destinationTabView = sender as TabView; + var destinationItems = destinationTabView.TabItems; + + if (destinationItems != null) + { + // First we need to get the position in the List to drop to + var index = -1; + + // Determine which items in the list our pointer is between. + for (int i = 0; i < destinationTabView.TabItems.Count; i++) + { + var item = destinationTabView.ContainerFromIndex(i) as TabViewItem; + + if (e.GetPosition(item).X - item.ActualWidth < 0) + { + index = i; + break; + } } // The TabViewItem can only be in one tree at a time. Before moving it to the new TabView, remove it from the old. // Note that this call can happen on a different thread if moving across windows. So make sure you call methods on // the same thread as where the UI Elements were created. - object header = null; - object dataContext = null; + object header = null; + object dataContext = null; var element = (obj as UIElement); var taskCompletionSource = new TaskCompletionSource(); @@ -190,25 +165,25 @@ private async void Tabs_TabStripDrop(object sender, DragEventArgs e) })); await taskCompletionSource.Task; - - var insertedItem = CreateNewTVI(header.ToString(), dataContext.ToString()); - if (index < 0) - { - // We didn't find a transition point, so we're at the end of the list - destinationItems.Add(insertedItem); - } - else if (index < destinationTabView.TabItems.Count) - { - // Otherwise, insert at the provided index. - destinationItems.Insert(index, insertedItem); - } - - // Select the newly dragged tab - destinationTabView.SelectedItem = insertedItem; - } - } - } - + + var insertedItem = CreateNewTVI(header.ToString(), dataContext.ToString()); + if (index < 0) + { + // We didn't find a transition point, so we're at the end of the list + destinationItems.Add(insertedItem); + } + else if (index < destinationTabView.TabItems.Count) + { + // Otherwise, insert at the provided index. + destinationItems.Insert(index, insertedItem); + } + + // Select the newly dragged tab + destinationTabView.SelectedItem = insertedItem; + } + } + } + private TabViewItem CreateNewTVI(string header, string dataContext) { var newTab = new TabViewItem() @@ -225,26 +200,26 @@ private TabViewItem CreateNewTVI(string header, string dataContext) }; return newTab; - } - - // This method prevents the TabView from handling things that aren't text (ie. files, images, etc.) - private void Tabs_TabStripDragOver(object sender, DragEventArgs e) - { - if (e.DataView.Properties.ContainsKey(DataIdentifier)) - { - e.AcceptedOperation = DataPackageOperation.Move; - } - } - - private void Tabs_AddTabButtonClick(TabView sender, object args) - { - var tab = CreateNewTVI("New Item", "New Item"); - sender.TabItems.Add(tab); - } - - private void Tabs_TabCloseRequested(TabView sender, TabViewTabCloseRequestedEventArgs args) - { - sender.TabItems.Remove(args.Tab); - } - } -} + } + + // This method prevents the TabView from handling things that aren't text (ie. files, images, etc.) + private void Tabs_TabStripDragOver(object sender, DragEventArgs e) + { + if (e.DataView.Properties.ContainsKey(DataIdentifier)) + { + e.AcceptedOperation = DataPackageOperation.Move; + } + } + + private void Tabs_AddTabButtonClick(TabView sender, object args) + { + var tab = CreateNewTVI("New Item", "New Item"); + sender.TabItems.Add(tab); + } + + private void Tabs_TabCloseRequested(TabView sender, TabViewTabCloseRequestedEventArgs args) + { + sender.TabItems.Remove(args.Tab); + } + } +} diff --git a/WinUIGallery/WinUIGallery.csproj b/WinUIGallery/WinUIGallery.csproj index 0ab4b6832..cd4d7d7d7 100644 --- a/WinUIGallery/WinUIGallery.csproj +++ b/WinUIGallery/WinUIGallery.csproj @@ -28,7 +28,7 @@ false true false - + true @@ -248,20 +248,4 @@ - - - true - - - $(CoreCompileDependsOn);GenerateDeploymentManagerCS - $(CoreCompileDependsOn);GenerateBootstrapCS - - - - - - - true - - \ No newline at end of file diff --git a/WinUIGallery/net6.override.targets b/WinUIGallery/net7.override.targets similarity index 100% rename from WinUIGallery/net6.override.targets rename to WinUIGallery/net7.override.targets diff --git a/WinUIGallery/standalone.props b/WinUIGallery/standalone.props index ab367c245..f3bcd37d4 100644 --- a/WinUIGallery/standalone.props +++ b/WinUIGallery/standalone.props @@ -1,8 +1,8 @@ - 1.4.230822000 - net6.0-windows10.0.19041.0 + net7.0-windows10.0.19041.0 + 1.4.231008000 6.2.11 1.0.4 2.0.13 diff --git a/nuget.config b/nuget.config index d1cfd30da..e793689e0 100644 --- a/nuget.config +++ b/nuget.config @@ -11,7 +11,7 @@ - +