From fa150ca42d8ea25c7809a85eb47810b273eda495 Mon Sep 17 00:00:00 2001 From: Mark Harper Date: Wed, 21 Oct 2020 10:24:12 -0700 Subject: [PATCH 1/6] Update AddProductWindow.xaml --- .../DataBindingDemo/AddProductWindow.xaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Sample Applications/DataBindingDemo/AddProductWindow.xaml b/Sample Applications/DataBindingDemo/AddProductWindow.xaml index ba8b1a3b9..2e521c3c5 100644 --- a/Sample Applications/DataBindingDemo/AddProductWindow.xaml +++ b/Sample Applications/DataBindingDemo/AddProductWindow.xaml @@ -57,9 +57,11 @@ Start Price: + Style="{StaticResource TextStyleTextBox}" Margin="8,5,0,5" + Validation.Error="OnValidationError"> - + @@ -71,9 +73,12 @@ + Style="{StaticResource TextStyleTextBox}" Margin="8,5,0,5" + Validation.Error="OnValidationError" + AutomationProperties.LiveSetting="Assertive"> From 440a0d646d565cf5adb4edef660433f2771eff9a Mon Sep 17 00:00:00 2001 From: Mark Harper Date: Wed, 21 Oct 2020 10:29:32 -0700 Subject: [PATCH 2/6] Update AuctionItem.cs --- Sample Applications/DataBindingDemo/AuctionItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sample Applications/DataBindingDemo/AuctionItem.cs b/Sample Applications/DataBindingDemo/AuctionItem.cs index b9a4723fa..63fef7301 100644 --- a/Sample Applications/DataBindingDemo/AuctionItem.cs +++ b/Sample Applications/DataBindingDemo/AuctionItem.cs @@ -103,7 +103,7 @@ public int StartPrice { if (value < 0) { - throw new ArgumentException("Price must be positive"); + throw new ArgumentException("Price must be positive. Provide a positive price"); } _startPrice = value; OnPropertyChanged("StartPrice"); From 6c644ec335b05b191205332b1aa866caf10d5d9a Mon Sep 17 00:00:00 2001 From: Mark Harper Date: Wed, 21 Oct 2020 10:32:53 -0700 Subject: [PATCH 3/6] Update AddProductWindow.cs --- .../DataBindingDemo/AddProductWindow.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Sample Applications/DataBindingDemo/AddProductWindow.cs b/Sample Applications/DataBindingDemo/AddProductWindow.cs index 844fd454a..57588907f 100644 --- a/Sample Applications/DataBindingDemo/AddProductWindow.cs +++ b/Sample Applications/DataBindingDemo/AddProductWindow.cs @@ -3,6 +3,9 @@ using System; using System.Windows; +using System.Windows.Automation; +using System.Windows.Automation.Peers; +using System.Windows.Controls; namespace DataBindingDemo { @@ -29,5 +32,20 @@ private void SubmitProduct(object sender, RoutedEventArgs e) ((App) Application.Current).AuctionItems.Add(item); Close(); } + + private void OnValidationError(object sender, ValidationErrorEventArgs e) + { + // Get the current UIA ItemStatus from the element element. + var oldStatus = AutomationProperties.GetItemStatus((DependencyObject)sender); + + // Set some sample new ItemStatus here... + var newStatus = e.Action == ValidationErrorEventAction.Added ? e.Error.ErrorContent.ToString() : String.Empty; + AutomationProperties.SetItemStatus((DependencyObject)sender, newStatus); + + // Having just set the new ItemStatus, raise a UIA property changed event. Note that the peer may + // be null here unless a UIA client app such as Narrator or the AccEvent SDK tool are running. + var automationPeer = UIElementAutomationPeer.FromElement((UIElement)sender); + automationPeer?.RaisePropertyChangedEvent(AutomationElementIdentifiers.ItemStatusProperty, oldStatus, newStatus); + } } -} \ No newline at end of file +} From e0f965062625df2441deaf5f6460dd80794df5c4 Mon Sep 17 00:00:00 2001 From: Mark Harper Date: Wed, 21 Oct 2020 10:36:40 -0700 Subject: [PATCH 4/6] Update FutureDateRule.cs --- Sample Applications/DataBindingDemo/FutureDateRule.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sample Applications/DataBindingDemo/FutureDateRule.cs b/Sample Applications/DataBindingDemo/FutureDateRule.cs index 7e823c61c..cce046b0f 100644 --- a/Sample Applications/DataBindingDemo/FutureDateRule.cs +++ b/Sample Applications/DataBindingDemo/FutureDateRule.cs @@ -18,13 +18,14 @@ public override ValidationResult Validate(object value, CultureInfo cultureInfo) } catch (FormatException) { - return new ValidationResult(false, "Value is not a valid date."); + return new ValidationResult(false, "Value is not a valid date. Please enter a valid date"); } if (DateTime.Now.Date > date) { - return new ValidationResult(false, "Please enter a date in the future."); + return new ValidationResult(false, "Value is not a future date. Please enter a date in the future."); } return ValidationResult.ValidResult; } + } -} \ No newline at end of file +} From 578be5fdf286d9ce989c0d51ff6668e78686c5f1 Mon Sep 17 00:00:00 2001 From: Mark Harper Date: Wed, 21 Oct 2020 10:39:49 -0700 Subject: [PATCH 5/6] Update MainWindow.cs --- .../DataBindingDemo/MainWindow.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Sample Applications/DataBindingDemo/MainWindow.cs b/Sample Applications/DataBindingDemo/MainWindow.cs index 6132bc682..cac82a3f2 100644 --- a/Sample Applications/DataBindingDemo/MainWindow.cs +++ b/Sample Applications/DataBindingDemo/MainWindow.cs @@ -1,8 +1,11 @@ // // Copyright (c) Microsoft. All rights reserved. // // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Collections.Specialized; using System.ComponentModel; using System.Windows; +using System.Windows.Automation; +using System.Windows.Automation.Peers; using System.Windows.Data; namespace DataBindingDemo @@ -41,11 +44,21 @@ private void AddGrouping(object sender, RoutedEventArgs args) // This groups the items in the view by the property "Category" var groupDescription = new PropertyGroupDescription {PropertyName = "Category"}; _listingDataView.GroupDescriptions.Add(groupDescription); + + NotifyUpdate(); + + } + + private void NotifyUpdate() + { + var listingPeer = ListBoxAutomationPeer.FromElement(Master); + listingPeer.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged); } private void RemoveGrouping(object sender, RoutedEventArgs args) { _listingDataView.GroupDescriptions.Clear(); + NotifyUpdate(); } private void AddSorting(object sender, RoutedEventArgs args) @@ -57,21 +70,26 @@ private void AddSorting(object sender, RoutedEventArgs args) new SortDescription("Category", ListSortDirection.Ascending)); _listingDataView.SortDescriptions.Add( new SortDescription("StartDate", ListSortDirection.Ascending)); + NotifyUpdate(); } private void RemoveSorting(object sender, RoutedEventArgs args) { _listingDataView.SortDescriptions.Clear(); + NotifyUpdate(); } private void AddFiltering(object sender, RoutedEventArgs args) { _listingDataView.Filter += ShowOnlyBargainsFilter; + NotifyUpdate(); } private void RemoveFiltering(object sender, RoutedEventArgs args) { _listingDataView.Filter -= ShowOnlyBargainsFilter; + NotifyUpdate(); } } -} \ No newline at end of file + +} From 6ff3cf665828cb863bafa043f97e0c4feeb99f42 Mon Sep 17 00:00:00 2001 From: Mark Harper Date: Wed, 21 Oct 2020 10:44:13 -0700 Subject: [PATCH 6/6] Update MainWindow.xaml --- Sample Applications/DataBindingDemo/MainWindow.xaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sample Applications/DataBindingDemo/MainWindow.xaml b/Sample Applications/DataBindingDemo/MainWindow.xaml index 4d8e2c45b..8c614af01 100644 --- a/Sample Applications/DataBindingDemo/MainWindow.xaml +++ b/Sample Applications/DataBindingDemo/MainWindow.xaml @@ -52,8 +52,9 @@ - + @@ -68,5 +69,6 @@