Skip to content

A Swiss Army knife for developers.

Fixed an issue where the navigation bar item would not resize properly in Release build.

Etienne Baudoux910e203fad39
diff --git a/src/dev/impl/DevToys/ViewModels/MainPageViewModel.cs b/src/dev/impl/DevToys/ViewModels/MainPageViewModel.cs
index cbd012637..d8d27aafe 100644
--- a/src/dev/impl/DevToys/ViewModels/MainPageViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/MainPageViewModel.cs
@@ -13,6 +13,7 @@ using DevToys.Models;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using Microsoft.Toolkit.Mvvm.Messaging;
+using Microsoft.UI.Xaml.Controls;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
@@ -25,7 +26,6 @@ using System.Web;
using Windows.Foundation;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
using ThreadPriority = DevToys.Core.Threading.ThreadPriority;
namespace DevToys.ViewModels
@@ -115,8 +115,7 @@ namespace DevToys.ViewModels
ThreadHelper.ThrowIfNotOnUIThread();
if (_searchQuery != value)
{
- _searchQuery = value;
- OnPropertyChanged();
+ SetProperty(ref _searchQuery, value);
UpdateMenuAsync(value).Forget();
}
}
@@ -133,8 +132,7 @@ namespace DevToys.ViewModels
ThreadHelper.ThrowIfNotOnUIThread();
if (_isInCompactOverlayMode != value)
{
- _isInCompactOverlayMode = value;
- OnPropertyChanged();
+ SetProperty(ref _isInCompactOverlayMode, value);
OnPropertyChanged(nameof(HeaderText));
OnPropertyChanged(nameof(WindowTitle));
}
@@ -150,8 +148,7 @@ namespace DevToys.ViewModels
set
{
ThreadHelper.ThrowIfNotOnUIThread();
- _navigationViewDisplayMode = value;
- OnPropertyChanged();
+ SetProperty(ref _navigationViewDisplayMode, value);
OnPropertyChanged(nameof(ActualNavigationViewDisplayMode));
}
}
@@ -165,8 +162,7 @@ namespace DevToys.ViewModels
set
{
ThreadHelper.ThrowIfNotOnUIThread();
- _isNavigationViewPaneOpened = value;
- OnPropertyChanged();
+ SetProperty(ref _isNavigationViewPaneOpened, value);
OnPropertyChanged(nameof(ActualNavigationViewDisplayMode));
}
}
diff --git a/src/dev/impl/DevToys/Views/MainPage.xaml b/src/dev/impl/DevToys/Views/MainPage.xaml
index 665da7a37..b1764fd92 100644
--- a/src/dev/impl/DevToys/Views/MainPage.xaml
+++ b/src/dev/impl/DevToys/Views/MainPage.xaml
@@ -5,13 +5,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:models="using:DevToys.Models"
xmlns:controls="using:DevToys.UI.Controls"
xmlns:converters="using:DevToys.UI.Converters"
xmlns:ex="using:DevToys.UI.Extensions"
- xmlns:models="using:DevToys.Models"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
- xmlns:icore="using:Microsoft.Xaml.Interactions.Core"
- xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:viewmanagement="using:Windows.UI.ViewManagement"
mc:Ignorable="d"
NavigationCacheMode="Enabled"
@@ -150,21 +148,11 @@
Header="{x:Bind ViewModel.HeaderText, Mode=OneWay}"
MenuItemsSource="{x:Bind ViewModel.ToolsMenuItems}"
FooterMenuItemsSource="{x:Bind ViewModel.FooterMenuItems}"
- SelectedItem="{x:Bind ViewModel.SelectedMenuItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
- <i:Interaction.Behaviors>
- <icore:EventTriggerBehavior EventName="DisplayModeChanged">
- <icore:ChangePropertyAction TargetObject="{x:Bind ViewModel}" PropertyName="NavigationViewDisplayMode" Value="{x:Bind NavigationView.DisplayMode, Mode=OneWay}"/>
- </icore:EventTriggerBehavior>
- <icore:EventTriggerBehavior EventName="PaneClosing">
- <icore:ChangePropertyAction TargetObject="{x:Bind ViewModel}" PropertyName="IsNavigationViewPaneOpened" Value="False"/>
- </icore:EventTriggerBehavior>
- <icore:EventTriggerBehavior EventName="PaneOpening">
- <icore:ChangePropertyAction TargetObject="{x:Bind ViewModel}" PropertyName="IsNavigationViewPaneOpened" Value="True"/>
- </icore:EventTriggerBehavior>
- <icore:EventTriggerBehavior EventName="Loaded">
- <icore:ChangePropertyAction TargetObject="{x:Bind ViewModel}" PropertyName="IsNavigationViewPaneOpened" Value="{x:Bind NavigationView.IsPaneOpen}"/>
- </icore:EventTriggerBehavior>
- </i:Interaction.Behaviors>
+ SelectedItem="{x:Bind ViewModel.SelectedMenuItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ DisplayModeChanged="NavigationView_DisplayModeChanged"
+ PaneClosing="NavigationView_PaneClosing"
+ PaneOpening="NavigationView_PaneOpening"
+ Loaded="NavigationView_Loaded">
<muxc:NavigationView.MenuItemTemplate>
<DataTemplate x:DataType="models:MatchedToolProviderViewData">
diff --git a/src/dev/impl/DevToys/Views/MainPage.xaml.cs b/src/dev/impl/DevToys/Views/MainPage.xaml.cs
index e52844256..aeb133273 100644
--- a/src/dev/impl/DevToys/Views/MainPage.xaml.cs
+++ b/src/dev/impl/DevToys/Views/MainPage.xaml.cs
@@ -75,6 +75,26 @@ namespace DevToys.Views
SearchBox.Focus(FocusState.Keyboard);
}
+ private void NavigationView_DisplayModeChanged(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewDisplayModeChangedEventArgs args)
+ {
+ ViewModel.NavigationViewDisplayMode = NavigationView.DisplayMode;
+ }
+
+ private void NavigationView_PaneClosing(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewPaneClosingEventArgs args)
+ {
+ ViewModel.IsNavigationViewPaneOpened = false;
+ }
+
+ private void NavigationView_PaneOpening(Microsoft.UI.Xaml.Controls.NavigationView sender, object args)
+ {
+ ViewModel.IsNavigationViewPaneOpened = true;
+ }
+
+ private void NavigationView_Loaded(object sender, RoutedEventArgs e)
+ {
+ ViewModel.IsNavigationViewPaneOpened = NavigationView.IsPaneOpen;
+ }
+
public void Receive(NavigateToToolMessage message)
{
Arguments.NotNull(message, nameof(message));
diff --git a/src/dev/impl/DevToys/Views/Tools/JsonFormatter/JsonFormatterToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/JsonFormatter/JsonFormatterToolPage.xaml
index 13d404543..de422fe65 100644
--- a/src/dev/impl/DevToys/Views/Tools/JsonFormatter/JsonFormatterToolPage.xaml
+++ b/src/dev/impl/DevToys/Views/Tools/JsonFormatter/JsonFormatterToolPage.xaml
@@ -30,6 +30,9 @@
VerticalAlignment="Stretch"
VerticalContentAlignment="Stretch"
Title="{x:Bind ViewModel.Strings.Indentation}">
+ <controls:ExpandableSettingControl.Icon>
+ <FontIcon Glyph="&#xF6F8;" />
+ </controls:ExpandableSettingControl.Icon>
<ComboBox
SelectedValuePath="Tag"
SelectedValue="{x:Bind ViewModel.Indentation, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">