Skip to content

A Swiss Army knife for developers.

Added IUIDropDownList

Etienne Baudoux0f2ad6a6059c
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDropDownList.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDropDownList.cs
new file mode 100644
index 000000000..e19cc2767
--- /dev/null
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDropDownList.cs
@@ -0,0 +1,147 @@
+namespace DevToys.Api;
+
+/// <summary>
+/// A component that represents a drop down list where the user can select one item in it.
+/// </summary>
+public interface IUIDropDownList : IUITitledElement
+{
+ /// <summary>
+ /// Gets the list of items displayed in the drop down list.
+ /// </summary>
+ IUIDropDownListItem[]? Items { get; }
+
+ /// <summary>
+ /// Gets the selected item in the drop down list.
+ /// </summary>
+ IUIDropDownListItem? SelectedItem { get; }
+
+ /// <summary>
+ /// Gets the action to run when the user selects an item in the list.
+ /// </summary>
+ Func<IUIDropDownListItem?, ValueTask>? OnItemSelectedAction { get; }
+
+ /// <summary>
+ /// Raised when <see cref="Items"/> is changed.
+ /// </summary>
+ public event EventHandler? ItemsChanged;
+
+ /// <summary>
+ /// Raised when <see cref="SelectedItem"/> is changed.
+ /// </summary>
+ public event EventHandler? SelectedItemChanged;
+}
+
+[DebuggerDisplay($"Id = {{{nameof(Id)}}}, Title = {{{nameof(Title)}}}")]
+internal sealed class UIDropDownList : UITitledElement, IUIDropDownList
+{
+ private IUIDropDownListItem[]? _items;
+ private IUIDropDownListItem? _selectedItem;
+
+ internal UIDropDownList(string? id)
+ : base(id)
+ {
+ }
+
+ public IUIDropDownListItem[]? Items
+ {
+ get => _items;
+ internal set
+ {
+ _items = value;
+ ItemsChanged?.Invoke(this, EventArgs.Empty);
+ }
+ }
+
+ public IUIDropDownListItem? SelectedItem
+ {
+ get => _selectedItem;
+ internal set
+ {
+ _selectedItem = value;
+ OnItemSelectedAction?.Invoke(_selectedItem);
+ SelectedItemChanged?.Invoke(this, EventArgs.Empty);
+ }
+ }
+
+ public Func<IUIDropDownListItem?, ValueTask>? OnItemSelectedAction { get; internal set; }
+
+ public event EventHandler? ItemsChanged;
+ public event EventHandler? SelectedItemChanged;
+}
+
+public static partial class GUI
+{
+ /// <summary>
+ /// A component that represents a drop down list where the user can select one item in it.
+ /// </summary>
+ public static IUIDropDownList DropDownList()
+ {
+ return DropDownList(null);
+ }
+
+ /// <summary>
+ /// A component that represents a drop down list where the user can select one item in it.
+ /// </summary>
+ /// <param name="id">An optional unique identifier for this UI element.</param>
+ public static IUIDropDownList DropDownList(string? id)
+ {
+ return new UIDropDownList(id);
+ }
+
+ /// <summary>
+ /// Sets the <see cref="IUIDropDownList.Items"/> of the drop down list.
+ /// </summary>
+ public static IUIDropDownList WithItems(this IUIDropDownList element, params IUIDropDownListItem[] items)
+ {
+ ((UIDropDownList)element).Items = items;
+ return element;
+ }
+
+ /// <summary>
+ /// Sets the action to run when selecting an item in the drop down list.
+ /// </summary>
+ public static IUIDropDownList OnItemSelected(this IUIDropDownList element, Func<IUIDropDownListItem?, ValueTask>? onItemSelectedAction)
+ {
+ ((UIDropDownList)element).OnItemSelectedAction = onItemSelectedAction;
+ return element;
+ }
+
+ /// <summary>
+ /// Sets the <see cref="IUIDropDownListItem"/> that should be selected in the drop down list.
+ /// If <paramref name="item"/> is null or does not exist in the list, no item will be selected.
+ /// </summary>
+ public static IUIDropDownList Select(this IUIDropDownList element, IUIDropDownListItem? item)
+ {
+ var dropDownList = (UIDropDownList)element;
+ if (item is not null && dropDownList.Items is not null && !dropDownList.Items.Contains(item))
+ {
+ dropDownList.SelectedItem = null;
+ }
+ else
+ {
+ dropDownList.SelectedItem = item;
+ }
+
+ return element;
+ }
+
+ /// <summary>
+ /// Sets the <see cref="IUIDropDownListItem"/> that should be selected in the drop down list, using its index in the list.
+ /// If <paramref name="index"/> smaller or greater than the amount of items in the list, no item will be selected.
+ /// </summary>
+ public static IUIDropDownList Select(this IUIDropDownList element, int index)
+ {
+ var dropDownList = (UIDropDownList)element;
+
+ if (dropDownList.Items is null || index < 0 || index > dropDownList.Items.Length - 1)
+ {
+ dropDownList.SelectedItem = null;
+ }
+ else
+ {
+ dropDownList.SelectedItem = dropDownList.Items[index];
+ }
+
+ return element;
+ }
+}
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDropDownListItem.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDropDownListItem.cs
new file mode 100644
index 000000000..a6395e162
--- /dev/null
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDropDownListItem.cs
@@ -0,0 +1,44 @@
+namespace DevToys.Api;
+
+/// <summary>
+/// A component that represents an item in a drop down list.
+/// </summary>
+public interface IUIDropDownListItem
+{
+ /// <summary>
+ /// Gets the text to display in the item.
+ /// </summary>
+ string? Text { get; }
+
+ /// <summary>
+ /// Gets the value associated to the item.
+ /// </summary>
+ object? Value { get; }
+}
+
+[DebuggerDisplay($"Text = {{{nameof(Text)}}}")]
+internal sealed class UIDropDownListItem : IUIDropDownListItem
+{
+ internal UIDropDownListItem(string? text, object? value)
+ {
+ Text = text;
+ Value = value;
+ }
+
+ public string? Text { get; }
+
+ public object? Value { get; }
+}
+
+public static partial class GUI
+{
+ /// <summary>
+ /// Create component that represents an item in a drop down list.
+ /// </summary>
+ /// <param name="text">The text to display in the item.</param>
+ /// <param name="value">The value associated to the item.</param>
+ public static IUIDropDownListItem Item(string? text, object? value)
+ {
+ return new UIDropDownListItem(text, value);
+ }
+}
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs
index 007de0cfc..231d1f59f 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs
@@ -1,4 +1,6 @@
-namespace DevToys.Api;
+using System;
+
+namespace DevToys.Api;
/// <summary>
/// A component that represents a setting, with a title, description, icon and <see cref="IUIElement"/> for the option value.
@@ -153,11 +155,57 @@ public static partial class GUI
toggleSwitch.OnToggle((bool state) =>
{
settingsProvider.SetSetting(settingDefinition, state);
- onToggled?.Invoke(state);
+ if (onToggled is not null)
+ {
+ return onToggled.Invoke(state);
+ }
return ValueTask.CompletedTask;
});
settingElement.InteractiveElement(toggleSwitch);
return element;
}
+
+ /// <summary>
+ /// Sets a <see cref="IUIDropDownList"/> to <see cref="IUISetting.InteractiveElement"/> and automatically associate the
+ /// given <paramref name="settingDefinition"/> to the switch state.
+ /// </summary>
+ /// <param name="settingsProvider">The settings provider used for handling the given <paramref name="settingDefinition"/>.</param>
+ /// <param name="settingDefinition">The definition of the setting to associate to this <see cref="IUISetting"/>.</param>
+ /// <param name="onOptionSelected">(optional) A method to invoke when the setting value changed.</param>
+ /// <param name="dropDownListItems">(optional) A list of items to be displayed in the drop down list. <see cref="IUIDropDownListItem.Value"/> should be of type <typeparamref name="T"/>.</param>
+ public static IUISetting Handle<T>(this IUISetting element, ISettingsProvider settingsProvider, SettingDefinition<T> settingDefinition, Func<T, ValueTask>? onOptionSelected, params IUIDropDownListItem[] dropDownListItems) where T : struct, IConvertible
+ {
+ if (!typeof(T).IsEnum)
+ {
+ ThrowHelper.ThrowArgumentException($"{nameof(T)} must be an enumerated type.");
+ }
+
+ var settingElement = (UISetting)element;
+
+ IUIDropDownList dropDownList
+ = DropDownList()
+ .WithItems(dropDownListItems);
+
+ T currentSettingValue = settingsProvider.GetSetting(settingDefinition);
+
+ dropDownList.Select(dropDownList.Items?.FirstOrDefault(i => i.Value is T e && e.ToInt32(null) == currentSettingValue.ToInt32(null)));
+
+ dropDownList.OnItemSelected((IUIDropDownListItem? item) =>
+ {
+ Guard.IsNotNull(item);
+ Guard.IsNotNull(item.Value);
+ Guard.IsOfType<T>(item.Value);
+
+ settingsProvider.SetSetting(settingDefinition, (T)item.Value);
+ if (onOptionSelected is not null)
+ {
+ return onOptionSelected.Invoke((T)item.Value);
+ }
+ return ValueTask.CompletedTask;
+ });
+
+ settingElement.InteractiveElement(dropDownList);
+ return element;
+ }
}
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs
index 0977ccf9c..57f8778fc 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs
@@ -101,27 +101,20 @@ public static partial class GUI
/// <param name="onToggled">(optional) A method to invoke when the setting value changed.</param>
public static IUISettingGroup Handle(this IUISettingGroup element, ISettingsProvider settingsProvider, SettingDefinition<bool> settingDefinition, Func<bool, ValueTask>? onToggled = null)
{
- var settingElement = (UISetting)element;
-
- IUISwitch toggleSwitch = Switch();
- if (settingsProvider.GetSetting(settingDefinition))
- {
- toggleSwitch.On();
- }
- else
- {
- toggleSwitch.Off();
- }
-
- toggleSwitch.OnToggle((bool state) =>
- {
- settingsProvider.SetSetting(settingDefinition, state);
- onToggled?.Invoke(state);
- return ValueTask.CompletedTask;
- });
+ return (IUISettingGroup)((IUISetting)element).Handle(settingsProvider, settingDefinition, onToggled);
+ }
- settingElement.InteractiveElement(toggleSwitch);
- return element;
+ /// <summary>
+ /// Sets a <see cref="IUIDropDownList"/> to <see cref="IUISetting.InteractiveElement"/> and automatically associate the
+ /// given <paramref name="settingDefinition"/> to the switch state.
+ /// </summary>
+ /// <param name="settingsProvider">The settings provider used for handling the given <paramref name="settingDefinition"/>.</param>
+ /// <param name="settingDefinition">The definition of the setting to associate to this <see cref="IUISetting"/>.</param>
+ /// <param name="onOptionSelected">(optional) A method to invoke when the setting value changed.</param>
+ /// <param name="dropDownListItems">(optional) A list of items to be displayed in the drop down list. <see cref="IUIDropDownListItem.Value"/> should be of type <typeparamref name="T"/>.</param>
+ public static IUISettingGroup Handle<T>(this IUISettingGroup element, ISettingsProvider settingsProvider, SettingDefinition<T> settingDefinition, Func<T, ValueTask>? onOptionSelected, params IUIDropDownListItem[] dropDownListItems) where T : struct, IConvertible
+ {
+ return (IUISettingGroup)((IUISetting)element).Handle<T>(settingsProvider, settingDefinition, onOptionSelected, dropDownListItems);
}
/// <summary>
diff --git a/src/app/dev/DevToys.Tools/Settings/SettingsGuiTool.cs b/src/app/dev/DevToys.Tools/Settings/SettingsGuiTool.cs
index 05db78898..4b54baffb 100644
--- a/src/app/dev/DevToys.Tools/Settings/SettingsGuiTool.cs
+++ b/src/app/dev/DevToys.Tools/Settings/SettingsGuiTool.cs
@@ -1,4 +1,6 @@
-namespace DevToys.Tools.Settings;
+using DevToys.Api.Core.Theme;
+
+namespace DevToys.Tools.Settings;
[Export(typeof(IGuiTool))]
[Name("Settings")]
@@ -25,7 +27,14 @@ internal sealed class SettingsGuiTool : IGuiTool
/// <summary>
/// Dummy setting
/// </summary>
- public static readonly SettingDefinition<bool> DummySetting = new(name: nameof(DummySetting), defaultValue: true);
+ public static readonly SettingDefinition<bool> DummySetting
+ = new(name: nameof(DummySetting), defaultValue: true);
+
+ /// <summary>
+ /// Dummy setting
+ /// </summary>
+ public static readonly SettingDefinition<AvailableApplicationTheme> DummySetting2
+ = new(name: nameof(DummySetting2), defaultValue: AvailableApplicationTheme.Default);
private readonly IUIButton _topLeftButton;
@@ -47,8 +56,13 @@ internal sealed class SettingsGuiTool : IGuiTool
.Icon("FluentSystemIcons", "\uF6A9")
.Title("Title")
.Description("Description")
- .InteractiveElement(
- Button().Text("My option"))
+ .Handle(
+ _settingsProvider,
+ DummySetting2,
+ OnDummySetting2ChangedAsync,
+ Item("Use system settings", AvailableApplicationTheme.Default),
+ Item("Light", AvailableApplicationTheme.Light),
+ Item("Dark", AvailableApplicationTheme.Dark))
.WithSettings(
Setting()
.Title("Title")
@@ -90,6 +104,16 @@ internal sealed class SettingsGuiTool : IGuiTool
return ValueTask.CompletedTask;
}
+ private ValueTask OnDropDownListSelectionChangeAsync(IUIDropDownListItem? selection)
+ {
+ return ValueTask.CompletedTask;
+ }
+
+ private ValueTask OnDummySetting2ChangedAsync(AvailableApplicationTheme theme)
+ {
+ return ValueTask.CompletedTask;
+ }
+
private ValueTask OnMyButtonClickAsync()
{
_clickCount++;
diff --git a/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIDropDownListPresenter.xaml b/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIDropDownListPresenter.xaml
new file mode 100644
index 000000000..695b857f8
--- /dev/null
+++ b/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIDropDownListPresenter.xaml
@@ -0,0 +1,12 @@
+<UserControl
+ x:Class="DevToys.UI.Framework.Controls.GuiTool.UIDropDownListPresenter"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:local="using:DevToys.UI.Framework.Controls.GuiTool"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ mc:Ignorable="d">
+ <ComboBox
+ x:Name="ComboBox"
+ Style="{ThemeResource DefaultComboBoxStyle}"/>
+</UserControl>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIDropDownListPresenter.xaml.cs b/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIDropDownListPresenter.xaml.cs
new file mode 100644
index 000000000..6eaf83cee
--- /dev/null
+++ b/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIDropDownListPresenter.xaml.cs
@@ -0,0 +1,106 @@
+using DevToys.Api;
+using Microsoft.UI.Xaml.Controls;
+
+namespace DevToys.UI.Framework.Controls.GuiTool;
+
+public sealed partial class UIDropDownListPresenter : UserControl
+{
+ public UIDropDownListPresenter()
+ {
+ this.InitializeComponent();
+
+ Loaded += UIDropDownListPresenter_Loaded;
+ Unloaded += UIDropDownListPresenter_Unloaded;
+ }
+
+ internal IUIDropDownList UIDropDownList => (IUIDropDownList)DataContext;
+
+ private void UIDropDownListPresenter_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
+ {
+ UIDropDownList.IsEnabledChanged += UIDropDownList_IsEnabledChanged;
+ UIDropDownList.IsVisibleChanged += UIDropDownList_IsVisibleChanged;
+ UIDropDownList.TitleChanged += UIDropDownList_TitleChanged;
+ UIDropDownList.ItemsChanged += UIDropDownList_ItemsChanged;
+ UIDropDownList.SelectedItemChanged += UIDropDownList_SelectedItemChanged;
+
+ IsEnabled = UIDropDownList.IsEnabled;
+ Visibility = UIDropDownList.IsVisible ? Microsoft.UI.Xaml.Visibility.Visible : Microsoft.UI.Xaml.Visibility.Collapsed;
+ ComboBox.Header = UIDropDownList.Title!;
+ SetItems();
+ if (UIDropDownList.Items is null)
+ {
+ ComboBox.SelectedIndex = -1;
+ }
+ else
+ {
+ ComboBox.SelectedIndex = Array.IndexOf(UIDropDownList.Items, UIDropDownList.SelectedItem);
+ }
+
+ ComboBox.SelectionChanged += UIDropDownListPresenter_SelectionChanged;
+ }
+
+ private void UIDropDownListPresenter_Unloaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
+ {
+ ComboBox.SelectionChanged -= UIDropDownListPresenter_SelectionChanged;
+ UIDropDownList.IsEnabledChanged -= UIDropDownList_IsEnabledChanged;
+ UIDropDownList.IsVisibleChanged -= UIDropDownList_IsVisibleChanged;
+ UIDropDownList.TitleChanged -= UIDropDownList_TitleChanged;
+ UIDropDownList.ItemsChanged -= UIDropDownList_ItemsChanged;
+ UIDropDownList.SelectedItemChanged -= UIDropDownList_SelectedItemChanged;
+ Loaded -= UIDropDownListPresenter_Loaded;
+ Unloaded -= UIDropDownListPresenter_Unloaded;
+ }
+
+ private void UIDropDownList_IsEnabledChanged(object? sender, EventArgs e)
+ {
+ IsEnabled = UIDropDownList.IsEnabled;
+ }
+
+ private void UIDropDownList_IsVisibleChanged(object? sender, EventArgs e)
+ {
+ Visibility = UIDropDownList.IsVisible ? Microsoft.UI.Xaml.Visibility.Visible : Microsoft.UI.Xaml.Visibility.Collapsed;
+ }
+
+ private void UIDropDownList_SelectedItemChanged(object? sender, EventArgs e)
+ {
+ if (UIDropDownList.Items is null)
+ {
+ ComboBox.SelectedIndex = -1;
+ }
+ else
+ {
+ ComboBox.SelectedIndex = Array.IndexOf(UIDropDownList.Items, UIDropDownList.SelectedItem);
+ }
+ }
+
+ private void UIDropDownList_ItemsChanged(object? sender, EventArgs e)
+ {
+ SetItems();
+ }
+
+ private void UIDropDownList_TitleChanged(object? sender, EventArgs e)
+ {
+ ComboBox.Header = UIDropDownList.Title!;
+ }
+
+ private void UIDropDownListPresenter_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ UIDropDownList.Select(ComboBox.SelectedIndex);
+ }
+
+ private void SetItems()
+ {
+ ComboBox.Items.Clear();
+ if (UIDropDownList.Items is not null)
+ {
+ for (int i = 0; i < UIDropDownList.Items.Length; i++)
+ {
+ ComboBox.Items.Add(new ComboBoxItem()
+ {
+ Tag = UIDropDownList.Items[i],
+ Content = UIDropDownList.Items[i].Text
+ });
+ }
+ }
+ }
+}
diff --git a/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIElementPresenter.xaml b/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIElementPresenter.xaml
index d03ad8501..9c716f10a 100644
--- a/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIElementPresenter.xaml
+++ b/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIElementPresenter.xaml
@@ -52,6 +52,13 @@
</DataTemplate>
</local:UIElementTemplateSelector.UISwitchTemplate>
+ <!-- UIDropDownList -->
+ <local:UIElementTemplateSelector.UIDropDownListTemplate>
+ <DataTemplate>
+ <local:UIDropDownListPresenter/>
+ </DataTemplate>
+ </local:UIElementTemplateSelector.UIDropDownListTemplate>
+
</local:UIElementTemplateSelector>
</Control.Resources>
diff --git a/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIElementTemplateSelector.cs b/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIElementTemplateSelector.cs
index 9f6e8745e..4867a8392 100644
--- a/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIElementTemplateSelector.cs
+++ b/src/app/dev/DevToys.UI.Framework/Controls/GuiTool/UIElementTemplateSelector.cs
@@ -39,6 +39,11 @@ internal sealed class UIElementTemplateSelector : DataTemplateSelector
/// </summary>
public DataTemplate UISwitchTemplate { get; set; } = null!;
+ /// <summary>
+ /// The data template used to display a <see cref="IUIDropDownList"/>.
+ /// </summary>
+ public DataTemplate UIDropDownListTemplate { get; set; } = null!;
+
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
{
if (item is null)
@@ -54,6 +59,7 @@ internal sealed class UIElementTemplateSelector : DataTemplateSelector
IUISettingGroup => UISettingGroupTemplate,
IUISetting => UISettingTemplate,
IUISwitch => UISwitchTemplate,
+ IUIDropDownList => UIDropDownListTemplate,
_ => throw new NotSupportedException($"Gui Tool component of type '{item.GetType().FullName}' isn't supported.")
};
diff --git a/src/app/dev/DevToys.UI.Framework/DevToys.UI.Framework.csproj b/src/app/dev/DevToys.UI.Framework/DevToys.UI.Framework.csproj
index 5cde0fb59..9c0d31e6a 100644
--- a/src/app/dev/DevToys.UI.Framework/DevToys.UI.Framework.csproj
+++ b/src/app/dev/DevToys.UI.Framework/DevToys.UI.Framework.csproj
@@ -22,8 +22,6 @@
</Page>
<PRIResource Include="**\*.resw" />
<Content Include="Assets\**" />
- <None Remove="Controls\GuiTool\UISwitchPresenter.xaml" />
- <UpToDateCheckInput Remove="Controls\GuiTool\UISwitchPresenter.xaml" />
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
@@ -99,10 +97,4 @@
<ProjectReference Include="..\DevToys.Api\DevToys.Api.csproj" />
</ItemGroup>
- <ItemGroup>
- <Compile Update="Controls\GuiTool\UISwitchPresenter.xaml.cs">
- <DependentUpon>UISwitchPresenter.xaml</DependentUpon>
- </Compile>
- </ItemGroup>
-
</Project>
diff --git a/src/app/dev/DevToys.UI/Views/ToolGroupPage.xaml b/src/app/dev/DevToys.UI/Views/ToolGroupPage.xaml
index f303e94e7..b8f5ab47e 100644
--- a/src/app/dev/DevToys.UI/Views/ToolGroupPage.xaml
+++ b/src/app/dev/DevToys.UI/Views/ToolGroupPage.xaml
@@ -12,7 +12,8 @@
xmlns:tools="using:DevToys.Core.Tools"
xmlns:toolstrings="using:DevToys.Localization.Strings.ToolPage"
xmlns:strings="using:DevToys.Localization.Strings.ToolGroupPage"
- mc:Ignorable="d">
+ mc:Ignorable="d"
+ NavigationCacheMode="Disabled">
<Page.Resources>
<Thickness x:Key="GridViewItemMargin">0,12,12,0</Thickness>
</Page.Resources>
diff --git a/src/app/dev/DevToys.UI/Views/ToolPage.xaml b/src/app/dev/DevToys.UI/Views/ToolPage.xaml
index cc19b31f3..6f9eb00c4 100644
--- a/src/app/dev/DevToys.UI/Views/ToolPage.xaml
+++ b/src/app/dev/DevToys.UI/Views/ToolPage.xaml
@@ -13,7 +13,8 @@
xmlns:tools="using:DevToys.Core.Tools"
xmlns:strings="using:DevToys.Localization.Strings.ToolPage"
xmlns:guiTool="using:DevToys.UI.Framework.Controls.GuiTool"
- mc:Ignorable="d">
+ mc:Ignorable="d"
+ NavigationCacheMode="Disabled">
<Page.Resources>
<converters:BooleanToStringConverter x:Key="BooleanToFavoriteIconGlyph" StringIfTrue="&#xF71A;" StringIfFalse="&#xF70F;"/>
</Page.Resources>
@@ -63,7 +64,7 @@
Grid.Row="0"
Grid.Column="0"
VerticalAlignment="Center"
- Text="{x:Bind ViewModel.HeaderText, Mode=OneWay}"
+ Text="{x:Bind ViewModel.HeaderText}"
TextTrimming="CharacterEllipsis"
FontSize="24"/>
<Border