diff --git a/src/CalcViewModel/CalcViewModel.vcxproj b/src/CalcViewModel/CalcViewModel.vcxproj
index f94732b7..4518c968 100644
--- a/src/CalcViewModel/CalcViewModel.vcxproj
+++ b/src/CalcViewModel/CalcViewModel.vcxproj
@@ -301,7 +301,6 @@
-
@@ -346,7 +345,6 @@
-
@@ -417,4 +415,4 @@
-
+
\ No newline at end of file
diff --git a/src/CalcViewModel/CalcViewModel.vcxproj.filters b/src/CalcViewModel/CalcViewModel.vcxproj.filters
index cfaa786f..511b9b60 100644
--- a/src/CalcViewModel/CalcViewModel.vcxproj.filters
+++ b/src/CalcViewModel/CalcViewModel.vcxproj.filters
@@ -61,9 +61,6 @@
Common\Automation
-
- Common\Automation
-
DataLoaders
@@ -161,9 +158,6 @@
Common\Automation
-
- Common\Automation
-
DataLoaders
@@ -209,4 +203,7 @@
DataLoaders
+
+
+
\ No newline at end of file
diff --git a/src/CalcViewModel/Common/Automation/NarratorNotifier.cpp b/src/CalcViewModel/Common/Automation/NarratorNotifier.cpp
deleted file mode 100644
index 9c60722f..00000000
--- a/src/CalcViewModel/Common/Automation/NarratorNotifier.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-// Implementation of the NarratorNotifier class.
-
-#include "pch.h"
-#include "NarratorNotifier.h"
-
-using namespace CalculatorApp::ViewModelNative::Common::Automation;
-using namespace Platform;
-using namespace Windows::UI::Xaml;
-using namespace Windows::UI::Xaml::Automation;
-using namespace Windows::UI::Xaml::Automation::Peers;
-
-DependencyProperty ^ NarratorNotifier::s_announcementProperty;
-
-NarratorNotifier::NarratorNotifier()
-{
-}
-
-void NarratorNotifier::Announce(NarratorAnnouncement ^ announcement)
-{
- if (NarratorAnnouncement::IsValid(announcement))
- {
- if (m_announcementElement == nullptr)
- {
- m_announcementElement = ref new Windows::UI::Xaml::Controls::TextBlock();
- }
-
- auto peer = FrameworkElementAutomationPeer::FromElement(m_announcementElement);
- if (peer != nullptr)
- {
- peer->RaiseNotificationEvent(announcement->Kind, announcement->Processing, announcement->Announcement, announcement->ActivityId);
- }
- }
-}
-
-void NarratorNotifier::RegisterDependencyProperties()
-{
- s_announcementProperty = DependencyProperty::Register(
- L"Announcement", // The name of the dependency property.
- NarratorAnnouncement::typeid, // The type of the dependency property.
- NarratorNotifier::typeid, // The owner of the dependency property.
- ref new PropertyMetadata(
- nullptr, // Default value of the dependency property.
- ref new PropertyChangedCallback(OnAnnouncementChanged)));
-}
-
-void NarratorNotifier::OnAnnouncementChanged(_In_ DependencyObject ^ dependencyObject, _In_ DependencyPropertyChangedEventArgs ^ e)
-{
- auto instance = safe_cast(dependencyObject);
- if (instance != nullptr)
- {
- instance->Announce(safe_cast(e->NewValue));
- }
-}
diff --git a/src/CalcViewModel/Common/Automation/NarratorNotifier.h b/src/CalcViewModel/Common/Automation/NarratorNotifier.h
deleted file mode 100644
index 7359b85f..00000000
--- a/src/CalcViewModel/Common/Automation/NarratorNotifier.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-// Declaration of the NarratorNotifier class.
-
-#pragma once
-#include "NarratorAnnouncement.h"
-
-namespace CalculatorApp::ViewModelNative::Common::Automation
-{
-public
- ref class NarratorNotifier sealed : public Windows::UI::Xaml::DependencyObject
- {
- public:
- NarratorNotifier();
-
- void Announce(NarratorAnnouncement ^ announcement);
-
- property NarratorAnnouncement^ Announcement
- {
- NarratorAnnouncement^ get() { return GetAnnouncement(this); }
- void set(NarratorAnnouncement^ value)
- {
- SetAnnouncement(this, value);
- }
- }
-
- static void RegisterDependencyProperties();
-
- static property Windows::UI::Xaml::DependencyProperty
- ^ AnnouncementProperty { Windows::UI::Xaml::DependencyProperty ^ get() { return s_announcementProperty; } }
-
- static NarratorAnnouncement
- ^ GetAnnouncement(
- Windows::UI::Xaml::DependencyObject ^ element) { return safe_cast(element->GetValue(s_announcementProperty)); }
-
- static void SetAnnouncement(Windows::UI::Xaml::DependencyObject ^ element, NarratorAnnouncement ^ value)
- {
- element->SetValue(s_announcementProperty, value);
- }
-
- private:
- static void OnAnnouncementChanged(
- _In_ Windows::UI::Xaml::DependencyObject ^ dependencyObject,
- _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ eventArgs);
-
- static Windows::UI::Xaml::DependencyProperty ^ s_announcementProperty;
-
- private:
- Windows::UI::Xaml::UIElement ^ m_announcementElement;
- };
-}
diff --git a/src/CalcViewModelCopyForUT/CalcViewModelCopyForUT.vcxproj b/src/CalcViewModelCopyForUT/CalcViewModelCopyForUT.vcxproj
index b77fd624..6c267d6c 100644
--- a/src/CalcViewModelCopyForUT/CalcViewModelCopyForUT.vcxproj
+++ b/src/CalcViewModelCopyForUT/CalcViewModelCopyForUT.vcxproj
@@ -296,7 +296,6 @@
-
@@ -341,7 +340,6 @@
-
@@ -411,4 +409,4 @@
-
+
\ No newline at end of file
diff --git a/src/CalcViewModelCopyForUT/CalcViewModelCopyForUT.vcxproj.filters b/src/CalcViewModelCopyForUT/CalcViewModelCopyForUT.vcxproj.filters
index 19ca2cee..5cb33274 100644
--- a/src/CalcViewModelCopyForUT/CalcViewModelCopyForUT.vcxproj.filters
+++ b/src/CalcViewModelCopyForUT/CalcViewModelCopyForUT.vcxproj.filters
@@ -21,9 +21,6 @@
Common\Automation
-
- Common\Automation
-
@@ -95,9 +92,6 @@
Common\Automation
-
- Common\Automation
-
diff --git a/src/Calculator/App.xaml.cs b/src/Calculator/App.xaml.cs
index 0d94ed32..c0468b49 100644
--- a/src/Calculator/App.xaml.cs
+++ b/src/Calculator/App.xaml.cs
@@ -7,7 +7,6 @@
//
using CalculatorApp.ViewModelNative.Common;
-using CalculatorApp.ViewModelNative.Common.Automation;
using System;
using System.Collections.Generic;
@@ -52,8 +51,6 @@ namespace CalculatorApp
m_preLaunched = false;
- RegisterDependencyProperties();
-
// TODO: MSFT 14645325: Set this directly from XAML.
// Currently this is bugged so the property is only respected from code-behind.
HighContrastAdjustment = ApplicationHighContrastAdjustment.None;
@@ -360,11 +357,6 @@ namespace CalculatorApp
_ = SetupJumpList();
}
- private void RegisterDependencyProperties()
- {
- NarratorNotifier.RegisterDependencyProperties();
- }
-
private void OnSuspending(object sender, SuspendingEventArgs args)
{
TraceLogger.GetInstance().LogButtonUsage();
diff --git a/src/Calculator/Views/Calculator.xaml b/src/Calculator/Views/Calculator.xaml
index 5a5125cc..5fedb549 100644
--- a/src/Calculator/Views/Calculator.xaml
+++ b/src/Calculator/Views/Calculator.xaml
@@ -1,7 +1,7 @@
+
@@ -101,6 +101,7 @@
PackageReference
+
@@ -131,4 +132,4 @@
-->
-
+
\ No newline at end of file
diff --git a/src/CalculatorApp.ViewModel/Common/Automation/NarratorNotifier.cs b/src/CalculatorApp.ViewModel/Common/Automation/NarratorNotifier.cs
new file mode 100644
index 00000000..0bf94eb1
--- /dev/null
+++ b/src/CalculatorApp.ViewModel/Common/Automation/NarratorNotifier.cs
@@ -0,0 +1,49 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using CalculatorApp.ViewModelNative.Common.Automation;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Automation.Peers;
+using Windows.UI.Xaml.Controls;
+
+namespace CalculatorApp.ViewModel.Common.Automation
+{
+ public class NarratorNotifier : DependencyObject
+ {
+ public static readonly DependencyProperty AnnouncementProperty =
+ DependencyProperty.Register(nameof(Announcement), typeof(NarratorAnnouncement), typeof(NarratorNotifier), new PropertyMetadata(null, (sender, args) =>
+ {
+ var self = (NarratorNotifier)sender;
+ self.Announce((NarratorAnnouncement)args.NewValue);
+ }));
+
+ public NarratorAnnouncement Announcement
+ {
+ get => (NarratorAnnouncement)GetValue(AnnouncementProperty);
+ set => SetValue(AnnouncementProperty, value);
+ }
+
+ public NarratorNotifier()
+ {
+ }
+
+ public void Announce(NarratorAnnouncement announcement)
+ {
+ if (NarratorAnnouncement.IsValid(announcement))
+ {
+ if (this.announcementElement == null)
+ {
+ this.announcementElement = new TextBlock();
+ }
+
+ var peer = FrameworkElementAutomationPeer.FromElement(this.announcementElement);
+ if (peer != null)
+ {
+ peer.RaiseNotificationEvent(announcement.Kind, announcement.Processing, announcement.Announcement, announcement.ActivityId);
+ }
+ }
+ }
+
+ private UIElement announcementElement;
+ }
+}