diff --git a/src/Calculator/Views/MainPage.xaml b/src/Calculator/Views/MainPage.xaml
index 1e40cd6..8fac3ea 100644
--- a/src/Calculator/Views/MainPage.xaml
+++ b/src/Calculator/Views/MainPage.xaml
@@ -2,14 +2,11 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:automation="using:CalculatorApp.ViewModel.Common.Automation"
- xmlns:common="using:CalculatorApp.Common"
- xmlns:controls="using:CalculatorApp.Controls"
xmlns:converters="using:CalculatorApp.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:CalculatorApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
- xmlns:vm="using:CalculatorApp.ViewModel"
x:Name="PageRoot"
muxc:BackdropMaterial.ApplyToRootOrPageBackground="True"
Loaded="OnPageLoaded"
@@ -85,8 +82,7 @@
+ Opened="Popup_Opened">
@@ -172,7 +167,7 @@
-
+
diff --git a/src/Calculator/Views/MainPage.xaml.cs b/src/Calculator/Views/MainPage.xaml.cs
index 1862b19..04c68a1 100644
--- a/src/Calculator/Views/MainPage.xaml.cs
+++ b/src/Calculator/Views/MainPage.xaml.cs
@@ -154,7 +154,7 @@ private void UpdatePopupSize(Windows.UI.Core.WindowSizeChangedEventArgs e)
if(PopupContent != null)
{
PopupContent.Width = e.Size.Width;
- PopupContent.Height = e.Size.Height - AppTitleBar.ActualHeight;
+ PopupContent.Height = e.Size.Height;
}
}
@@ -300,7 +300,7 @@ private void EnsurePopupContent()
var windowBounds = Window.Current.Bounds;
PopupContent.Width = windowBounds.Width;
- PopupContent.Height = windowBounds.Height - AppTitleBar.ActualHeight;
+ PopupContent.Height = windowBounds.Height;
}
}
@@ -578,14 +578,9 @@ private void AnnounceCategoryName()
NarratorNotifier.Announce(announcement);
}
- private void TitleBarBackButtonClick(object sender, RoutedEventArgs e)
+ private bool ShouldShowBackButton(bool isAlwaysOnTop, bool isPopupOpen)
{
- CloseSettingsPopup();
- }
-
- private Visibility ShouldShowBackButton(bool isAlwaysOnTop, bool isPopupOpen)
- {
- return !isAlwaysOnTop && isPopupOpen ? Visibility.Visible : Visibility.Collapsed;
+ return !isAlwaysOnTop && isPopupOpen;
}
private double NavigationViewOpenPaneLength(bool isAlwaysOnTop)
@@ -593,6 +588,16 @@ private double NavigationViewOpenPaneLength(bool isAlwaysOnTop)
return isAlwaysOnTop ? 0 : (double)Application.Current.Resources["SplitViewOpenPaneLength"];
}
+ private GridLength DoubleToGridLength(double value)
+ {
+ return new GridLength(value);
+ }
+
+ private void Settings_BackButtonClick(object sender, RoutedEventArgs e)
+ {
+ CloseSettingsPopup();
+ }
+
private CalculatorApp.Calculator m_calculator;
private GraphingCalculator m_graphingCalculator;
private CalculatorApp.UnitConverter m_converter;
diff --git a/src/Calculator/Views/Settings.xaml b/src/Calculator/Views/Settings.xaml
index 3c699cd..e25dc4d 100644
--- a/src/Calculator/Views/Settings.xaml
+++ b/src/Calculator/Views/Settings.xaml
@@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:automation="using:CalculatorApp.ViewModel.Common.Automation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="using:CalculatorApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
Loaded="OnLoaded"
@@ -40,6 +39,10 @@
+
+
+
+
@@ -77,7 +80,20 @@
-
+
+
@@ -86,7 +102,8 @@
Style="{StaticResource CategoryNameTextBlockStyle}"/>
-
diff --git a/src/Calculator/Views/Settings.xaml.cs b/src/Calculator/Views/Settings.xaml.cs
index 715f3b1..b2a54d0 100644
--- a/src/Calculator/Views/Settings.xaml.cs
+++ b/src/Calculator/Views/Settings.xaml.cs
@@ -12,12 +12,10 @@
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Controls.Primitives;
-using Windows.UI.Xaml.Data;
-using Windows.UI.Xaml.Input;
-using Windows.UI.Xaml.Media;
-using Windows.UI.Xaml.Navigation;
using CalculatorApp.ViewModel.Common.Automation;
+using Windows.UI.Core;
+using Windows.UI.Xaml.Automation.Peers;
+using Windows.UI.Xaml.Automation.Provider;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
@@ -29,6 +27,16 @@ public sealed partial class Settings : UserControl
// BUILD_YEAR was a C++/CX macro and may update the value from the pipeline
private const string BUILD_YEAR = "2021";
+ public event Windows.UI.Xaml.RoutedEventHandler BackButtonClick;
+
+ public GridLength TitleBarHeight
+ {
+ get { return (GridLength)GetValue(TitleBarHeightProperty); }
+ set { SetValue(TitleBarHeightProperty, value); }
+ }
+ public static readonly DependencyProperty TitleBarHeightProperty =
+ DependencyProperty.Register(nameof(TitleBarHeight), typeof(GridLength), typeof(Settings), new PropertyMetadata(default(GridLength)));
+
public Settings()
{
var locService = LocalizationService.GetInstance();
@@ -63,6 +71,8 @@ public void SetDefaultFocus()
// OnLoaded would be invoked by Popup several times while contructed once
private void OnLoaded(object sender, RoutedEventArgs args)
{
+ SystemNavigationManager.GetForCurrentView().BackRequested += System_BackRequested;
+
AnnouncePageOpened();
var currentTheme = ThemeHelper.RootTheme.ToString();
@@ -83,6 +93,8 @@ private void OnUnloaded(object sender, RoutedEventArgs e)
{
// back to the default state
AppThemeExpander.IsExpanded = false;
+
+ SystemNavigationManager.GetForCurrentView().BackRequested -= System_BackRequested;
}
private void FeedbackButton_Click(object sender, RoutedEventArgs e)
@@ -131,5 +143,22 @@ private void InitializeContributeTextBlock()
ContributeRunLink.Text = contributeTextLink;
ContributeRunAfterLink.Text = contributeTextAfterHyperlink;
}
+
+ private void System_BackRequested(object sender, BackRequestedEventArgs e)
+ {
+ if (!e.Handled && BackButton.IsEnabled)
+ {
+ var buttonPeer = new ButtonAutomationPeer(BackButton);
+ IInvokeProvider invokeProvider = buttonPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
+ invokeProvider.Invoke();
+
+ e.Handled = true;
+ }
+ }
+
+ private void BackButton_Click(object sender, RoutedEventArgs e)
+ {
+ BackButtonClick?.Invoke(this, e);
+ }
}
}
diff --git a/src/Calculator/Views/TitleBar.xaml b/src/Calculator/Views/TitleBar.xaml
index a9da216..afb0eba 100644
--- a/src/Calculator/Views/TitleBar.xaml
+++ b/src/Calculator/Views/TitleBar.xaml
@@ -27,9 +27,7 @@
-
-
-
+
@@ -47,19 +45,6 @@
-
-
diff --git a/src/Calculator/Views/TitleBar.xaml.cs b/src/Calculator/Views/TitleBar.xaml.cs
index 8c02f16..ced0518 100644
--- a/src/Calculator/Views/TitleBar.xaml.cs
+++ b/src/Calculator/Views/TitleBar.xaml.cs
@@ -1,16 +1,10 @@
using CalculatorApp.ViewModel.Common;
-using System;
-using System.ComponentModel;
using Windows.ApplicationModel.Core;
using Windows.System.Profile;
-using Windows.UI;
using Windows.UI.Core;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
-using Windows.UI.Xaml.Automation.Peers;
-using Windows.UI.Xaml.Automation.Provider;
using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Media;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
@@ -53,7 +47,6 @@ public bool IsAlwaysOnTopMode
}));
public event Windows.UI.Xaml.RoutedEventHandler AlwaysOnTopClick;
- public event Windows.UI.Xaml.RoutedEventHandler BackButtonClick;
private void OnLoaded(object sender, RoutedEventArgs e)
{
@@ -65,9 +58,6 @@ private void OnLoaded(object sender, RoutedEventArgs e)
m_accessibilitySettings.HighContrastChanged += OnHighContrastChanged;
Window.Current.Activated += OnWindowActivated;
- // Register the system back requested event
- SystemNavigationManager.GetForCurrentView().BackRequested += System_BackRequested;
-
// Register RequestedTheme changed callback to update title bar system button colors.
m_rootFrameRequestedThemeCallbackToken =
Utils.ThemeHelper.RegisterAppThemeChangedCallback(RootFrame_RequestedThemeChanged);
@@ -93,24 +83,10 @@ private void OnUnloaded(object sender, RoutedEventArgs e)
m_accessibilitySettings.HighContrastChanged -= OnHighContrastChanged;
Window.Current.Activated -= OnWindowActivated;
- SystemNavigationManager.GetForCurrentView().BackRequested -= System_BackRequested;
-
Utils.ThemeHelper.
UnregisterAppThemeChangedCallback(m_rootFrameRequestedThemeCallbackToken);
}
- private void System_BackRequested(object sender, BackRequestedEventArgs e)
- {
- if (!e.Handled && BackButton.IsEnabled)
- {
- var buttonPeer = new ButtonAutomationPeer(BackButton);
- IInvokeProvider invokeProvider = buttonPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
- invokeProvider.Invoke();
-
- e.Handled = true;
- }
- }
-
private void RootFrame_RequestedThemeChanged(DependencyObject sender, DependencyProperty dp)
{
if(Frame.RequestedThemeProperty == dp)
@@ -231,11 +207,6 @@ private void AlwaysOnTopButton_Click(object sender, RoutedEventArgs e)
AlwaysOnTopClick?.Invoke(this, e);
}
- private void BackButton_Click(object sender, RoutedEventArgs e)
- {
- BackButtonClick?.Invoke(this, e);
- }
-
// Dependency properties for the color of the system title bar buttons
public Windows.UI.Xaml.Media.SolidColorBrush ButtonBackground
{
@@ -301,18 +272,18 @@ public Windows.UI.Xaml.Media.SolidColorBrush ButtonPressedForeground
public static readonly DependencyProperty ButtonPressedForegroundProperty =
DependencyProperty.Register(nameof(ButtonPressedForeground), typeof(Windows.UI.Xaml.Media.SolidColorBrush), typeof(TitleBar), new PropertyMetadata(null));
- public Visibility BackButtonVisibility
+ public bool BackButtonSpaceReserved
{
- get { return (Visibility)GetValue(BackButtonVisibilityProperty); }
- set { SetValue(BackButtonVisibilityProperty, value); }
+ get => (bool)GetValue(BackButtonSpaceReservedProperty);
+ set => SetValue(BackButtonSpaceReservedProperty, value);
}
- public static readonly DependencyProperty BackButtonVisibilityProperty =
+ public static readonly DependencyProperty BackButtonSpaceReservedProperty =
DependencyProperty.Register(
- nameof(BackButtonVisibility), typeof(Visibility), typeof(TitleBar),
- new PropertyMetadata(false, new PropertyChangedCallback((sender, args) => {
+ nameof(BackButtonSpaceReserved), typeof(bool), typeof(TitleBar),
+ new PropertyMetadata(false, new PropertyChangedCallback((sender, args)=> {
var self = sender as TitleBar;
VisualStateManager.GoToState(
- self, (Visibility)args.NewValue == Visibility.Visible ? self.BackButtonVisible.Name : self.BackButtonCollapsed.Name, true);
+ self, (bool)args.NewValue ? self.BackButtonVisible.Name : self.BackButtonCollapsed.Name, true);
})));
private Windows.ApplicationModel.Core.CoreApplicationViewTitleBar m_coreTitleBar;