diff --git a/AIDevGallery/Controls/SampleContainer.xaml b/AIDevGallery/Controls/SampleContainer.xaml index 864dbbb3..0f786b2e 100644 --- a/AIDevGallery/Controls/SampleContainer.xaml +++ b/AIDevGallery/Controls/SampleContainer.xaml @@ -109,23 +109,14 @@ Visibility="Visible" /> diff --git a/AIDevGallery/Controls/SampleContainer.xaml.cs b/AIDevGallery/Controls/SampleContainer.xaml.cs index 9169eb7e..ce8921c3 100644 --- a/AIDevGallery/Controls/SampleContainer.xaml.cs +++ b/AIDevGallery/Controls/SampleContainer.xaml.cs @@ -342,12 +342,15 @@ public void ShowDebugInfo(string? contents) SampleDebugInfoButtonText.Visibility = Visibility.Collapsed; SampleDebugInfoButton.Visibility = Visibility.Collapsed; SampleDebugInfoButtonText.Text = string.Empty; - SampleDebugInfoContent.Text = string.Empty; + ToolTipService.SetToolTip(SampleDebugInfoButton, null); + Microsoft.UI.Xaml.Automation.AutomationProperties.SetFullDescription(SampleDebugInfoButton, string.Empty); return; } SampleDebugInfoButtonText.Text = contents.Split('\n')[0]; - SampleDebugInfoContent.Text = contents; + + ToolTipService.SetToolTip(SampleDebugInfoButton, contents); + Microsoft.UI.Xaml.Automation.AutomationProperties.SetFullDescription(SampleDebugInfoButton, contents); SampleDebugInfoButtonText.Visibility = Visibility.Visible; SampleDebugInfoButton.Visibility = Visibility.Visible; diff --git a/AIDevGallery/Helpers/NavigationViewItemHelper.cs b/AIDevGallery/Helpers/NavigationViewItemHelper.cs index bd1a81cc..0fae3387 100644 --- a/AIDevGallery/Helpers/NavigationViewItemHelper.cs +++ b/AIDevGallery/Helpers/NavigationViewItemHelper.cs @@ -1,6 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Automation; +using Microsoft.UI.Xaml.Automation.Peers; using Microsoft.UI.Xaml.Controls; using System.Collections.Generic; using System.Linq; @@ -9,6 +12,28 @@ namespace AIDevGallery.Helpers; internal static class NavigationViewItemHelper { + public static void AppendControlTypeToName(this NavigationViewItem item, string label) + { + RoutedEventHandler? loadedHandler = null; + loadedHandler = (sender, _) => + { + if (sender is not NavigationViewItem navItem) + { + return; + } + + var peer = FrameworkElementAutomationPeer.FromElement(navItem) ?? FrameworkElementAutomationPeer.CreatePeerForElement(navItem); + var controlType = peer?.GetLocalizedControlType(); + if (!string.IsNullOrWhiteSpace(controlType)) + { + AutomationProperties.SetName(navItem, $"{label}, {controlType}"); + navItem.Loaded -= loadedHandler; + } + }; + + item.Loaded += loadedHandler; + } + public static IEnumerable Flatten(this IEnumerable source) { foreach (var item in source) diff --git a/AIDevGallery/Pages/APIs/APIOverview.xaml b/AIDevGallery/Pages/APIs/APIOverview.xaml index 766e472f..b8f30680 100644 --- a/AIDevGallery/Pages/APIs/APIOverview.xaml +++ b/AIDevGallery/Pages/APIs/APIOverview.xaml @@ -108,11 +108,13 @@ item["Text"]); + return; } + + string query = sender.Text; + var searchResults = await Search(query); + + if (sender.Text != query) + { + return; + } + + var suggestions = searchResults.Select(item => item["Text"]).ToList(); + sender.ItemsSource = suggestions; + + NarratorHelper.Announce(sender, $"{suggestions.Count} result{(suggestions.Count == 1 ? string.Empty : "s")}", "SemanticComboBoxSuggestionsActivityId"); // } private static void OnEmbeddingGeneratorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)