Register the events in the XAML, not the CS file

This commit is contained in:
Rose 2022-09-29 10:39:10 -04:00
commit cdaaddd6b9
2 changed files with 2 additions and 9 deletions

View file

@ -690,6 +690,7 @@
<Flyout x:Name="HistoryFlyout"
AutomationProperties.AutomationId="HistoryFlyout"
Closed="HistoryFlyout_Closed"
Closing="HistoryFlyout_Closing"
FlyoutPresenterStyle="{StaticResource HistoryFlyoutStyle}"
Opened="HistoryFlyout_Opened"
Placement="Full"/>
@ -788,6 +789,7 @@
x:Uid="MemoryFlyout"
AutomationProperties.AutomationId="MemoryFlyout"
Closed="OnMemoryFlyoutClosed"
Closing="OnMemoryFlyoutClosing"
FlyoutPresenterStyle="{StaticResource MemoryFlyoutStyle}"
Opened="OnMemoryFlyoutOpened"
Placement="Full"/>

View file

@ -225,9 +225,6 @@ namespace CalculatorApp
string memoryPaneName = AppResourceProvider.GetInstance().GetResourceString("MemoryPane");
MemoryFlyout.FlyoutPresenterStyle.Setters.Add(new Setter(AutomationProperties.NameProperty, memoryPaneName));
HistoryFlyout.Closing += HistoryFlyout_Closing;
MemoryFlyout.Closing += OnMemoryFlyoutClosing;
// Delay load things later when we get a chance.
WeakReference weakThis = new WeakReference(this);
_ = this.Dispatcher.RunAsync(
@ -647,9 +644,6 @@ namespace CalculatorApp
private void HistoryFlyout_Closed(object sender, object args)
{
// Ideally, this would be renamed in the Closing event because the Closed event is too late.
// Closing is not available until RS1+ so we set the name again here for TH2 support.
AutomationProperties.SetName(HistoryButton, m_openHistoryFlyoutAutomationName);
m_fIsHistoryFlyoutOpen = false;
EnableControls(true);
if (HistoryButton.IsEnabled && HistoryButton.Visibility == Visibility.Visible)
@ -742,9 +736,6 @@ namespace CalculatorApp
private void OnMemoryFlyoutClosed(object sender, object args)
{
// Ideally, this would be renamed in the Closing event because the Closed event is too late.
// Closing is not available until RS1+ so we set the name again here for TH2 support.
AutomationProperties.SetName(MemoryButton, m_openMemoryFlyoutAutomationName);
m_fIsMemoryFlyoutOpen = false;
EnableControls(true);
if (MemoryButton.IsEnabled)