diff --git a/.github/workflows/wpf-ui-cd-nuget.yaml b/.github/workflows/wpf-ui-cd-nuget.yaml
index 9fd8c41e7..4c19d45ea 100644
--- a/.github/workflows/wpf-ui-cd-nuget.yaml
+++ b/.github/workflows/wpf-ui-cd-nuget.yaml
@@ -28,6 +28,9 @@ jobs:
- name: Build
run: dotnet build src\Wpf.Ui\Wpf.Ui.csproj --configuration Release --no-restore -p:SourceLinkEnabled=true
+ - name: Build
+ run: dotnet build src\Wpf.Ui.Abstractions\Wpf.Ui.Abstractions.csproj --configuration Release --no-restore -p:SourceLinkEnabled=true
+
- name: Build
run: dotnet build src\Wpf.Ui.Tray\Wpf.Ui.Tray.csproj --configuration Release --no-restore -p:SourceLinkEnabled=true
diff --git a/Directory.Build.props b/Directory.Build.props
index 452a106b7..f41b3dcea 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,36 +1,28 @@
+
- 3.0.5
- 12.0
- true
+ $(MSBuildThisFileDirectory)
+ $(RepositoryDirectory)build\
- net8.0-windows;net7.0-windows;net6.0-windows;net481;net472;net462
+ 4.0.0-rc.1
- enable
- enable
- $(Version)
- lepo.co
lepo.co
- Copyright (C) 2021-2024 Leszek Pomianowski and WPF UI Contributors
- true
+ lepo.co
+ WPF-UI
+ lepoco;toolkit;wpf;fluent;navigation;controls;design;icons;system;accent;theme;winui
MIT
- https://raw.githubusercontent.com/lepoco/wpfui/main/LICENSE
+ true
+ Copyright (C) 2021-2024 Leszek Pomianowski and WPF UI Contributors
https://github.com/lepoco/wpfui
https://github.com/lepoco/wpfui/releases
- https://github.com/lepoco/wpfui
+ Icon.png
+ https://github.com/lepoco/wpfui/main/build/nuget.png
main
git
- WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
- wpf ui wpfui fluent design winui windows controls custom metro modern xaml toolkit color dark theme lepo net6 net5 net
- README.md
-
-
-
- true
@@ -41,18 +33,32 @@
true
-
-
-
+
+ true
+ true
+
-
-
-
+
+ true
+ 12.0
+ enable
+
+
+ $(NoWarn);CS8500
+
+
+
+ $(MSBuildProjectName.Contains('Test'))
+ False
+ True
+
-
- <_Parameter1>$(MSBuildProjectName).UnitTests
-
+
diff --git a/Directory.Build.targets b/Directory.Build.targets
index c9fb730d2..8a271aa74 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -1,4 +1,89 @@
+
+
+ true
+
+
+
+ $(CommonTags);.NET
+ $(CommonTags);$(PackageTags)
+ $(CommonTags)
+
+
+
+ true
+ README.md
+ false
+ true
+ snupkg
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+ <_Parameter1>CommitHash
+ <_Parameter2>$(SourceRevisionId)
+
+
+
+
+
+
+ true
+ true
+ true
+ true
+
+
+
+
+ $(IntermediateOutputPath)$(MSBuildProjectName).SkipLocalsInit.g.cs
+
+
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+[module: global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PerMonitor
+ true/PM
+ true
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Wpf.Ui.Demo.Mvvm/applicationIcon.ico b/samples/Wpf.Ui.Demo.Dialogs/applicationIcon.ico
similarity index 100%
rename from src/Wpf.Ui.Demo.Mvvm/applicationIcon.ico
rename to samples/Wpf.Ui.Demo.Dialogs/applicationIcon.ico
diff --git a/src/Wpf.Ui.Demo.Mvvm/App.xaml b/samples/Wpf.Ui.Demo.Mvvm/App.xaml
similarity index 100%
rename from src/Wpf.Ui.Demo.Mvvm/App.xaml
rename to samples/Wpf.Ui.Demo.Mvvm/App.xaml
diff --git a/src/Wpf.Ui.Demo.Mvvm/App.xaml.cs b/samples/Wpf.Ui.Demo.Mvvm/App.xaml.cs
similarity index 89%
rename from src/Wpf.Ui.Demo.Mvvm/App.xaml.cs
rename to samples/Wpf.Ui.Demo.Mvvm/App.xaml.cs
index bc2ed1e5b..652455eca 100644
--- a/src/Wpf.Ui.Demo.Mvvm/App.xaml.cs
+++ b/samples/Wpf.Ui.Demo.Mvvm/App.xaml.cs
@@ -7,9 +7,9 @@
using System.Windows.Threading;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
using Wpf.Ui.Demo.Mvvm.Models;
using Wpf.Ui.Demo.Mvvm.Services;
+using Wpf.Ui.DependencyInjection;
namespace Wpf.Ui.Demo.Mvvm;
@@ -36,12 +36,11 @@ public partial class App
.ConfigureServices(
(context, services) =>
{
+ _ = services.AddNavigationViewPageProvider();
+
// App Host
_ = services.AddHostedService();
- // Page resolver service
- _ = services.AddSingleton();
-
// Theme manipulation
_ = services.AddSingleton();
@@ -70,14 +69,11 @@ public partial class App
.Build();
///
- /// Gets registered service.
+ /// Gets services.
///
- /// Type of the service to get.
- /// Instance of the service or .
- public static T? GetService()
- where T : class
+ public static IServiceProvider Services
{
- return _host.Services.GetService(typeof(T)) as T;
+ get { return _host.Services; }
}
///
diff --git a/samples/Wpf.Ui.Demo.Mvvm/AssemblyInfo.cs b/samples/Wpf.Ui.Demo.Mvvm/AssemblyInfo.cs
new file mode 100644
index 000000000..89adb40fb
--- /dev/null
+++ b/samples/Wpf.Ui.Demo.Mvvm/AssemblyInfo.cs
@@ -0,0 +1,6 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
diff --git a/samples/Wpf.Ui.Demo.Mvvm/Assets/applicationIcon-1024.png b/samples/Wpf.Ui.Demo.Mvvm/Assets/applicationIcon-1024.png
new file mode 100644
index 000000000..b70c4ed59
Binary files /dev/null and b/samples/Wpf.Ui.Demo.Mvvm/Assets/applicationIcon-1024.png differ
diff --git a/src/Wpf.Ui.Demo.Simple/Assets/applicationIcon-256.png b/samples/Wpf.Ui.Demo.Mvvm/Assets/applicationIcon-256.png
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/Assets/applicationIcon-256.png
rename to samples/Wpf.Ui.Demo.Mvvm/Assets/applicationIcon-256.png
diff --git a/samples/Wpf.Ui.Demo.Mvvm/GlobalUsings.cs b/samples/Wpf.Ui.Demo.Mvvm/GlobalUsings.cs
new file mode 100644
index 000000000..d01a3845c
--- /dev/null
+++ b/samples/Wpf.Ui.Demo.Mvvm/GlobalUsings.cs
@@ -0,0 +1,15 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+global using System;
+global using System.Collections.Generic;
+global using System.Globalization;
+global using System.Linq;
+global using System.Threading;
+global using System.Threading.Tasks;
+global using System.Windows;
+global using CommunityToolkit.Mvvm.ComponentModel;
+global using CommunityToolkit.Mvvm.Input;
+global using Microsoft.Extensions.Hosting;
diff --git a/src/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs b/samples/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs
similarity index 97%
rename from src/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs
rename to samples/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs
index e2c8c8fc6..4df817714 100644
--- a/src/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs
+++ b/samples/Wpf.Ui.Demo.Mvvm/Helpers/EnumToBooleanConverter.cs
@@ -3,7 +3,6 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using System.Globalization;
using System.Windows.Data;
namespace Wpf.Ui.Demo.Mvvm.Helpers;
diff --git a/src/Wpf.Ui.Demo.Mvvm/Models/AppConfig.cs b/samples/Wpf.Ui.Demo.Mvvm/Models/AppConfig.cs
similarity index 100%
rename from src/Wpf.Ui.Demo.Mvvm/Models/AppConfig.cs
rename to samples/Wpf.Ui.Demo.Mvvm/Models/AppConfig.cs
diff --git a/src/Wpf.Ui.Demo.Mvvm/Models/DataColor.cs b/samples/Wpf.Ui.Demo.Mvvm/Models/DataColor.cs
similarity index 100%
rename from src/Wpf.Ui.Demo.Mvvm/Models/DataColor.cs
rename to samples/Wpf.Ui.Demo.Mvvm/Models/DataColor.cs
diff --git a/src/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs b/samples/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs
similarity index 79%
rename from src/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs
rename to samples/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs
index f8187a529..1c1ed62f6 100644
--- a/src/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs
+++ b/samples/Wpf.Ui.Demo.Mvvm/Services/ApplicationHostService.cs
@@ -3,7 +3,6 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using Microsoft.Extensions.Hosting;
using Wpf.Ui.Demo.Mvvm.Views;
namespace Wpf.Ui.Demo.Mvvm.Services;
@@ -11,16 +10,10 @@ namespace Wpf.Ui.Demo.Mvvm.Services;
///
/// Managed host of the application.
///
-public class ApplicationHostService : IHostedService
+public class ApplicationHostService(IServiceProvider serviceProvider) : IHostedService
{
- private readonly IServiceProvider _serviceProvider;
private INavigationWindow? _navigationWindow;
- public ApplicationHostService(IServiceProvider serviceProvider)
- {
- _serviceProvider = serviceProvider;
- }
-
///
/// Triggered when the application host is ready to start the service.
///
@@ -48,9 +41,7 @@ private async Task HandleActivationAsync()
if (!Application.Current.Windows.OfType().Any())
{
- _navigationWindow = (
- _serviceProvider.GetService(typeof(INavigationWindow)) as INavigationWindow
- )!;
+ _navigationWindow = (serviceProvider.GetService(typeof(INavigationWindow)) as INavigationWindow)!;
_navigationWindow!.ShowWindow();
_ = _navigationWindow.Navigate(typeof(Views.Pages.DashboardPage));
diff --git a/src/Wpf.Ui.Demo.Mvvm/ViewModels/DashboardViewModel.cs b/samples/Wpf.Ui.Demo.Mvvm/ViewModels/DashboardViewModel.cs
similarity index 75%
rename from src/Wpf.Ui.Demo.Mvvm/ViewModels/DashboardViewModel.cs
rename to samples/Wpf.Ui.Demo.Mvvm/ViewModels/DashboardViewModel.cs
index 5f0ebdacb..4658c4d7d 100644
--- a/src/Wpf.Ui.Demo.Mvvm/ViewModels/DashboardViewModel.cs
+++ b/samples/Wpf.Ui.Demo.Mvvm/ViewModels/DashboardViewModel.cs
@@ -1,11 +1,11 @@
-// This Source Code Form is subject to the terms of the MIT License.
+// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
namespace Wpf.Ui.Demo.Mvvm.ViewModels;
-public partial class DashboardViewModel : ObservableObject
+public partial class DashboardViewModel : ViewModel
{
[ObservableProperty]
private int _counter = 0;
diff --git a/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs b/samples/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs
similarity index 88%
rename from src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs
rename to samples/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs
index f97d43c7e..cbe43ff9c 100644
--- a/src/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs
+++ b/samples/Wpf.Ui.Demo.Mvvm/ViewModels/DataViewModel.cs
@@ -4,19 +4,18 @@
// All Rights Reserved.
using System.Windows.Media;
-using Wpf.Ui.Controls;
using Wpf.Ui.Demo.Mvvm.Models;
namespace Wpf.Ui.Demo.Mvvm.ViewModels;
-public partial class DataViewModel : ObservableObject, INavigationAware
+public partial class DataViewModel : ViewModel
{
private bool _isInitialized = false;
[ObservableProperty]
private List _colors = [];
- public void OnNavigatedTo()
+ public override void OnNavigatedTo()
{
if (!_isInitialized)
{
@@ -24,8 +23,6 @@ public void OnNavigatedTo()
}
}
- public void OnNavigatedFrom() { }
-
private void InitializeViewModel()
{
var random = new Random();
diff --git a/src/Wpf.Ui.Demo.Mvvm/ViewModels/MainWindowViewModel.cs b/samples/Wpf.Ui.Demo.Mvvm/ViewModels/MainWindowViewModel.cs
similarity index 97%
rename from src/Wpf.Ui.Demo.Mvvm/ViewModels/MainWindowViewModel.cs
rename to samples/Wpf.Ui.Demo.Mvvm/ViewModels/MainWindowViewModel.cs
index 990764610..079533861 100644
--- a/src/Wpf.Ui.Demo.Mvvm/ViewModels/MainWindowViewModel.cs
+++ b/samples/Wpf.Ui.Demo.Mvvm/ViewModels/MainWindowViewModel.cs
@@ -8,7 +8,7 @@
namespace Wpf.Ui.Demo.Mvvm.ViewModels;
-public partial class MainWindowViewModel : ObservableObject
+public partial class MainWindowViewModel : ViewModel
{
private bool _isInitialized = false;
diff --git a/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs b/samples/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs
similarity index 92%
rename from src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs
rename to samples/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs
index 3d6f6f613..5b6faa818 100644
--- a/src/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs
+++ b/samples/Wpf.Ui.Demo.Mvvm/ViewModels/SettingsViewModel.cs
@@ -3,11 +3,9 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using Wpf.Ui.Controls;
-
namespace Wpf.Ui.Demo.Mvvm.ViewModels;
-public partial class SettingsViewModel : ObservableObject, INavigationAware
+public partial class SettingsViewModel : ViewModel
{
private bool _isInitialized = false;
@@ -20,7 +18,7 @@ public partial class SettingsViewModel : ObservableObject, INavigationAware
.ApplicationTheme
.Unknown;
- public void OnNavigatedTo()
+ public override void OnNavigatedTo()
{
if (!_isInitialized)
{
@@ -28,8 +26,6 @@ public void OnNavigatedTo()
}
}
- public void OnNavigatedFrom() { }
-
private void InitializeViewModel()
{
CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationThemeManager.GetAppTheme();
diff --git a/samples/Wpf.Ui.Demo.Mvvm/ViewModels/ViewModel.cs b/samples/Wpf.Ui.Demo.Mvvm/ViewModels/ViewModel.cs
new file mode 100644
index 000000000..3fbc133ab
--- /dev/null
+++ b/samples/Wpf.Ui.Demo.Mvvm/ViewModels/ViewModel.cs
@@ -0,0 +1,55 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+using Wpf.Ui.Abstractions.Controls;
+
+namespace Wpf.Ui.Demo.Mvvm.ViewModels;
+
+public abstract class ViewModel : ObservableObject, INavigationAware
+{
+ ///
+ public virtual async Task OnNavigatedToAsync()
+ {
+ using CancellationTokenSource cts = new();
+
+ await DispatchAsync(OnNavigatedTo, cts.Token);
+ }
+
+ ///
+ /// Handles the event that is fired after the component is navigated to.
+ ///
+ // ReSharper disable once MemberCanBeProtected.Global
+ public virtual void OnNavigatedTo() { }
+
+ ///
+ public virtual async Task OnNavigatedFromAsync()
+ {
+ using CancellationTokenSource cts = new();
+
+ await DispatchAsync(OnNavigatedFrom, cts.Token);
+ }
+
+ ///
+ /// Handles the event that is fired before the component is navigated from.
+ ///
+ // ReSharper disable once MemberCanBeProtected.Global
+ public virtual void OnNavigatedFrom() { }
+
+ ///
+ /// Dispatches the specified action on the UI thread.
+ ///
+ /// The action to be dispatched.
+ /// A cancellation token that can be used to cancel the operation.
+ /// A task that represents the asynchronous operation.
+ protected static async Task DispatchAsync(Action action, CancellationToken cancellationToken)
+ {
+ if (cancellationToken.IsCancellationRequested)
+ {
+ return;
+ }
+
+ await Application.Current.Dispatcher.InvokeAsync(action);
+ }
+}
diff --git a/src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml b/samples/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml
similarity index 100%
rename from src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml
rename to samples/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml
diff --git a/src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs b/samples/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs
similarity index 89%
rename from src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs
rename to samples/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs
index b2280e8e4..c5a712452 100644
--- a/src/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs
+++ b/samples/Wpf.Ui.Demo.Mvvm/Views/MainWindow.xaml.cs
@@ -3,6 +3,7 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
+using Wpf.Ui.Abstractions;
using Wpf.Ui.Controls;
namespace Wpf.Ui.Demo.Mvvm.Views;
@@ -16,7 +17,6 @@ public partial class MainWindow : INavigationWindow
public MainWindow(
ViewModels.MainWindowViewModel viewModel,
- IPageService pageService,
INavigationService navigationService
)
{
@@ -26,7 +26,6 @@ INavigationService navigationService
Appearance.SystemThemeWatcher.Watch(this);
InitializeComponent();
- SetPageService(pageService);
navigationService.SetNavigationControl(RootNavigation);
}
@@ -35,7 +34,8 @@ INavigationService navigationService
public bool Navigate(Type pageType) => RootNavigation.Navigate(pageType);
- public void SetPageService(IPageService pageService) => RootNavigation.SetPageService(pageService);
+ public void SetPageService(INavigationViewPageProvider navigationViewPageProvider) =>
+ RootNavigation.SetPageProviderService(navigationViewPageProvider);
public void ShowWindow() => Show();
diff --git a/src/Wpf.Ui.Demo.Mvvm/Views/Pages/DashboardPage.xaml b/samples/Wpf.Ui.Demo.Mvvm/Views/Pages/DashboardPage.xaml
similarity index 100%
rename from src/Wpf.Ui.Demo.Mvvm/Views/Pages/DashboardPage.xaml
rename to samples/Wpf.Ui.Demo.Mvvm/Views/Pages/DashboardPage.xaml
diff --git a/src/Wpf.Ui.Demo.Mvvm/Views/Pages/DashboardPage.xaml.cs b/samples/Wpf.Ui.Demo.Mvvm/Views/Pages/DashboardPage.xaml.cs
similarity index 85%
rename from src/Wpf.Ui.Demo.Mvvm/Views/Pages/DashboardPage.xaml.cs
rename to samples/Wpf.Ui.Demo.Mvvm/Views/Pages/DashboardPage.xaml.cs
index e56b545e7..7aea5e908 100644
--- a/src/Wpf.Ui.Demo.Mvvm/Views/Pages/DashboardPage.xaml.cs
+++ b/samples/Wpf.Ui.Demo.Mvvm/Views/Pages/DashboardPage.xaml.cs
@@ -1,9 +1,9 @@
-// This Source Code Form is subject to the terms of the MIT License.
+// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using Wpf.Ui.Controls;
+using Wpf.Ui.Abstractions.Controls;
namespace Wpf.Ui.Demo.Mvvm.Views.Pages;
diff --git a/src/Wpf.Ui.Demo.Mvvm/Views/Pages/DataPage.xaml b/samples/Wpf.Ui.Demo.Mvvm/Views/Pages/DataPage.xaml
similarity index 100%
rename from src/Wpf.Ui.Demo.Mvvm/Views/Pages/DataPage.xaml
rename to samples/Wpf.Ui.Demo.Mvvm/Views/Pages/DataPage.xaml
diff --git a/src/Wpf.Ui.Demo.Mvvm/Views/Pages/DataPage.xaml.cs b/samples/Wpf.Ui.Demo.Mvvm/Views/Pages/DataPage.xaml.cs
similarity index 85%
rename from src/Wpf.Ui.Demo.Mvvm/Views/Pages/DataPage.xaml.cs
rename to samples/Wpf.Ui.Demo.Mvvm/Views/Pages/DataPage.xaml.cs
index 9a1f38ff3..43330c98a 100644
--- a/src/Wpf.Ui.Demo.Mvvm/Views/Pages/DataPage.xaml.cs
+++ b/samples/Wpf.Ui.Demo.Mvvm/Views/Pages/DataPage.xaml.cs
@@ -1,9 +1,9 @@
-// This Source Code Form is subject to the terms of the MIT License.
+// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using Wpf.Ui.Controls;
+using Wpf.Ui.Abstractions.Controls;
namespace Wpf.Ui.Demo.Mvvm.Views.Pages;
diff --git a/src/Wpf.Ui.Demo.Mvvm/Views/Pages/SettingsPage.xaml b/samples/Wpf.Ui.Demo.Mvvm/Views/Pages/SettingsPage.xaml
similarity index 100%
rename from src/Wpf.Ui.Demo.Mvvm/Views/Pages/SettingsPage.xaml
rename to samples/Wpf.Ui.Demo.Mvvm/Views/Pages/SettingsPage.xaml
diff --git a/src/Wpf.Ui.Demo.Mvvm/Views/Pages/SettingsPage.xaml.cs b/samples/Wpf.Ui.Demo.Mvvm/Views/Pages/SettingsPage.xaml.cs
similarity index 85%
rename from src/Wpf.Ui.Demo.Mvvm/Views/Pages/SettingsPage.xaml.cs
rename to samples/Wpf.Ui.Demo.Mvvm/Views/Pages/SettingsPage.xaml.cs
index 1abdff60e..4af851510 100644
--- a/src/Wpf.Ui.Demo.Mvvm/Views/Pages/SettingsPage.xaml.cs
+++ b/samples/Wpf.Ui.Demo.Mvvm/Views/Pages/SettingsPage.xaml.cs
@@ -1,9 +1,9 @@
-// This Source Code Form is subject to the terms of the MIT License.
+// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using Wpf.Ui.Controls;
+using Wpf.Ui.Abstractions.Controls;
namespace Wpf.Ui.Demo.Mvvm.Views.Pages;
diff --git a/src/Wpf.Ui.Demo.Mvvm/Wpf.Ui.Demo.Mvvm.csproj b/samples/Wpf.Ui.Demo.Mvvm/Wpf.Ui.Demo.Mvvm.csproj
similarity index 57%
rename from src/Wpf.Ui.Demo.Mvvm/Wpf.Ui.Demo.Mvvm.csproj
rename to samples/Wpf.Ui.Demo.Mvvm/Wpf.Ui.Demo.Mvvm.csproj
index 46ca00a9d..7e24cbdd1 100644
--- a/src/Wpf.Ui.Demo.Mvvm/Wpf.Ui.Demo.Mvvm.csproj
+++ b/samples/Wpf.Ui.Demo.Mvvm/Wpf.Ui.Demo.Mvvm.csproj
@@ -9,7 +9,6 @@
applicationIcon.ico
AnyCPU;x64
$(NoWarn);SA1601
- True
@@ -27,9 +26,10 @@
-
-
-
+
+
+
+
@@ -37,15 +37,4 @@
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
diff --git a/src/Wpf.Ui.Demo.Mvvm/app.manifest b/samples/Wpf.Ui.Demo.Mvvm/app.manifest
similarity index 100%
rename from src/Wpf.Ui.Demo.Mvvm/app.manifest
rename to samples/Wpf.Ui.Demo.Mvvm/app.manifest
diff --git a/src/Wpf.Ui.Demo.Simple/applicationIcon.ico b/samples/Wpf.Ui.Demo.Mvvm/applicationIcon.ico
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/applicationIcon.ico
rename to samples/Wpf.Ui.Demo.Mvvm/applicationIcon.ico
diff --git a/src/Wpf.Ui.Demo.Simple/App.xaml b/samples/Wpf.Ui.Demo.Simple/App.xaml
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/App.xaml
rename to samples/Wpf.Ui.Demo.Simple/App.xaml
diff --git a/src/Wpf.Ui.Demo.Simple/App.xaml.cs b/samples/Wpf.Ui.Demo.Simple/App.xaml.cs
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/App.xaml.cs
rename to samples/Wpf.Ui.Demo.Simple/App.xaml.cs
diff --git a/src/Wpf.Ui.Demo.Simple/AssemblyInfo.cs b/samples/Wpf.Ui.Demo.Simple/AssemblyInfo.cs
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/AssemblyInfo.cs
rename to samples/Wpf.Ui.Demo.Simple/AssemblyInfo.cs
diff --git a/samples/Wpf.Ui.Demo.Simple/Assets/applicationIcon-1024.png b/samples/Wpf.Ui.Demo.Simple/Assets/applicationIcon-1024.png
new file mode 100644
index 000000000..b70c4ed59
Binary files /dev/null and b/samples/Wpf.Ui.Demo.Simple/Assets/applicationIcon-1024.png differ
diff --git a/samples/Wpf.Ui.Demo.Simple/Assets/applicationIcon-256.png b/samples/Wpf.Ui.Demo.Simple/Assets/applicationIcon-256.png
new file mode 100644
index 000000000..6b5cf5d5a
Binary files /dev/null and b/samples/Wpf.Ui.Demo.Simple/Assets/applicationIcon-256.png differ
diff --git a/src/Wpf.Ui.Demo.Simple/MainWindow.xaml b/samples/Wpf.Ui.Demo.Simple/MainWindow.xaml
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/MainWindow.xaml
rename to samples/Wpf.Ui.Demo.Simple/MainWindow.xaml
diff --git a/src/Wpf.Ui.Demo.Simple/MainWindow.xaml.cs b/samples/Wpf.Ui.Demo.Simple/MainWindow.xaml.cs
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/MainWindow.xaml.cs
rename to samples/Wpf.Ui.Demo.Simple/MainWindow.xaml.cs
diff --git a/src/Wpf.Ui.Demo.Simple/Models/DataColor.cs b/samples/Wpf.Ui.Demo.Simple/Models/DataColor.cs
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/Models/DataColor.cs
rename to samples/Wpf.Ui.Demo.Simple/Models/DataColor.cs
diff --git a/src/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml b/samples/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml
rename to samples/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml
diff --git a/src/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml.cs b/samples/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml.cs
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml.cs
rename to samples/Wpf.Ui.Demo.Simple/Views/Pages/DashboardPage.xaml.cs
diff --git a/src/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml b/samples/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml
rename to samples/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml
diff --git a/src/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml.cs b/samples/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml.cs
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml.cs
rename to samples/Wpf.Ui.Demo.Simple/Views/Pages/DataPage.xaml.cs
diff --git a/src/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml b/samples/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml
rename to samples/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml
diff --git a/src/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml.cs b/samples/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml.cs
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml.cs
rename to samples/Wpf.Ui.Demo.Simple/Views/Pages/SettingsPage.xaml.cs
diff --git a/src/Wpf.Ui.Demo.Simple/Wpf.Ui.Demo.Simple.csproj b/samples/Wpf.Ui.Demo.Simple/Wpf.Ui.Demo.Simple.csproj
similarity index 53%
rename from src/Wpf.Ui.Demo.Simple/Wpf.Ui.Demo.Simple.csproj
rename to samples/Wpf.Ui.Demo.Simple/Wpf.Ui.Demo.Simple.csproj
index d8ca1bb84..ea1f29ef8 100644
--- a/src/Wpf.Ui.Demo.Simple/Wpf.Ui.Demo.Simple.csproj
+++ b/samples/Wpf.Ui.Demo.Simple/Wpf.Ui.Demo.Simple.csproj
@@ -9,7 +9,6 @@
applicationIcon.ico
AnyCPU;x64
$(NoWarn);SA1601
- True
@@ -22,9 +21,9 @@
-
-
-
+
+
+
@@ -32,15 +31,4 @@
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
diff --git a/src/Wpf.Ui.Demo.Simple/app.manifest b/samples/Wpf.Ui.Demo.Simple/app.manifest
similarity index 100%
rename from src/Wpf.Ui.Demo.Simple/app.manifest
rename to samples/Wpf.Ui.Demo.Simple/app.manifest
diff --git a/samples/Wpf.Ui.Demo.Simple/applicationIcon.ico b/samples/Wpf.Ui.Demo.Simple/applicationIcon.ico
new file mode 100644
index 000000000..cc128fda3
Binary files /dev/null and b/samples/Wpf.Ui.Demo.Simple/applicationIcon.ico differ
diff --git a/src/Wpf.Ui/Controls/NavigationView/INavigableView.cs b/src/Wpf.Ui.Abstractions/Controls/INavigableView.cs
similarity index 81%
rename from src/Wpf.Ui/Controls/NavigationView/INavigableView.cs
rename to src/Wpf.Ui.Abstractions/Controls/INavigableView.cs
index 22671313f..a7057c3f9 100644
--- a/src/Wpf.Ui/Controls/NavigationView/INavigableView.cs
+++ b/src/Wpf.Ui.Abstractions/Controls/INavigableView.cs
@@ -3,18 +3,17 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-// ReSharper disable once CheckNamespace
-namespace Wpf.Ui.Controls;
+namespace Wpf.Ui.Abstractions.Controls;
///
-/// A component whose ViewModel is separate from the DataContext and can be navigated by .
+/// A component whose ViewModel is separate from the DataContext and can be navigated by INavigationView.
///
/// The type of the ViewModel associated with the view. This type optionally may implement to participate in navigation processes.
public interface INavigableView
{
///
/// Gets the view model used by the view.
- /// Optionally, it may implement and be navigated by .
+ /// Optionally, it may implement and be navigated by INavigationView.
///
T ViewModel { get; }
}
diff --git a/src/Wpf.Ui/Controls/NavigationView/INavigationAware.cs b/src/Wpf.Ui.Abstractions/Controls/INavigationAware.cs
similarity index 50%
rename from src/Wpf.Ui/Controls/NavigationView/INavigationAware.cs
rename to src/Wpf.Ui.Abstractions/Controls/INavigationAware.cs
index 586aedbd6..8843b52cb 100644
--- a/src/Wpf.Ui/Controls/NavigationView/INavigationAware.cs
+++ b/src/Wpf.Ui.Abstractions/Controls/INavigationAware.cs
@@ -3,8 +3,7 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-// ReSharper disable once CheckNamespace
-namespace Wpf.Ui.Controls;
+namespace Wpf.Ui.Abstractions.Controls;
///
/// Notifies class about being navigated.
@@ -12,12 +11,15 @@ namespace Wpf.Ui.Controls;
public interface INavigationAware
{
///
- /// Method triggered when the class is navigated.
+ /// Asynchronously handles the event that is fired after the component is navigated to.
///
- void OnNavigatedTo();
+ /// A task that represents the asynchronous operation.
+
+ Task OnNavigatedToAsync();
///
- /// Method triggered when the navigation leaves the current class.
+ /// Asynchronously handles the event that is fired before the component is navigated from.
///
- void OnNavigatedFrom();
+ /// A task that represents the asynchronous operation.
+ Task OnNavigatedFromAsync();
}
diff --git a/src/Wpf.Ui.Abstractions/Controls/NavigationAware.cs b/src/Wpf.Ui.Abstractions/Controls/NavigationAware.cs
new file mode 100644
index 000000000..2c371d80f
--- /dev/null
+++ b/src/Wpf.Ui.Abstractions/Controls/NavigationAware.cs
@@ -0,0 +1,40 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+namespace Wpf.Ui.Abstractions.Controls;
+
+///
+/// Provides a base class for navigation-aware components.
+///
+public abstract class NavigationAware : INavigationAware
+{
+ ///
+ public virtual Task OnNavigatedToAsync()
+ {
+ OnNavigatedTo();
+
+ return Task.CompletedTask;
+ }
+
+ ///
+ /// Handles the event that is fired after the component is navigated to.
+ ///
+ // ReSharper disable once MemberCanBeProtected.Global
+ public virtual void OnNavigatedTo() { }
+
+ ///
+ public virtual Task OnNavigatedFromAsync()
+ {
+ OnNavigatedFrom();
+
+ return Task.CompletedTask;
+ }
+
+ ///
+ /// Handles the event that is fired before the component is navigated from.
+ ///
+ // ReSharper disable once MemberCanBeProtected.Global
+ public virtual void OnNavigatedFrom() { }
+}
diff --git a/src/Wpf.Ui.Abstractions/GlobalUsings.cs b/src/Wpf.Ui.Abstractions/GlobalUsings.cs
new file mode 100644
index 000000000..2f59ea353
--- /dev/null
+++ b/src/Wpf.Ui.Abstractions/GlobalUsings.cs
@@ -0,0 +1,7 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+global using System;
+global using System.Threading.Tasks;
diff --git a/src/Wpf.Ui.Abstractions/INavigationViewPageProvider.cs b/src/Wpf.Ui.Abstractions/INavigationViewPageProvider.cs
new file mode 100644
index 000000000..d983f743b
--- /dev/null
+++ b/src/Wpf.Ui.Abstractions/INavigationViewPageProvider.cs
@@ -0,0 +1,19 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+namespace Wpf.Ui.Abstractions;
+
+///
+/// Defines a service that provides pages for navigation.
+///
+public interface INavigationViewPageProvider
+{
+ ///
+ /// Retrieves a page of the specified type.
+ ///
+ /// The type of the page to retrieve.
+ /// An instance of the specified page type, or null if the page is not found.
+ public object? GetPage(Type pageType);
+}
diff --git a/src/Wpf.Ui.Abstractions/NavigationException.cs b/src/Wpf.Ui.Abstractions/NavigationException.cs
new file mode 100644
index 000000000..ccf3b9981
--- /dev/null
+++ b/src/Wpf.Ui.Abstractions/NavigationException.cs
@@ -0,0 +1,27 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+namespace Wpf.Ui.Abstractions;
+
+///
+/// Represents errors that occur during navigation.
+///
+public sealed class NavigationException : Exception
+{
+ ///
+ /// Initializes a new instance of the NavigationException class with a specified error message.
+ ///
+ /// The message that describes the error.
+ public NavigationException(string message)
+ : base(message) { }
+
+ ///
+ /// Initializes a new instance of the NavigationException class with a specified error message and a reference to the inner exception that is the cause of this exception.
+ ///
+ /// The exception that is the cause of the current exception.
+ /// The message that describes the error.
+ public NavigationException(Exception e, string message)
+ : base(message, e) { }
+}
diff --git a/src/Wpf.Ui.Abstractions/NavigationViewPageProviderExtensions.cs b/src/Wpf.Ui.Abstractions/NavigationViewPageProviderExtensions.cs
new file mode 100644
index 000000000..a5d4554d8
--- /dev/null
+++ b/src/Wpf.Ui.Abstractions/NavigationViewPageProviderExtensions.cs
@@ -0,0 +1,39 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+namespace Wpf.Ui.Abstractions;
+
+///
+/// Provides extension methods for the INavigationViewPageProvider interface.
+///
+public static class NavigationViewPageProviderExtensions
+{
+ ///
+ /// Retrieves a page of the specified type from the page service.
+ ///
+ /// The type of the page to retrieve.
+ /// The page service instance.
+ /// An instance of the specified page type, or null if the page is not found.
+ public static TPage? GetPage(this INavigationViewPageProvider navigationViewPageProvider)
+ where TPage : class
+ {
+ return navigationViewPageProvider.GetPage(typeof(TPage)) as TPage;
+ }
+
+ ///
+ /// Retrieves a page of the specified type from the page service.
+ /// Throws a NavigationException if the page is not found.
+ ///
+ /// The type of the page to retrieve.
+ /// The page service instance.
+ /// An instance of the specified page type.
+ /// Thrown when the specified page type is not found.
+ public static TPage GetRequiredPage(this INavigationViewPageProvider navigationViewPageProvider)
+ where TPage : class
+ {
+ return navigationViewPageProvider.GetPage(typeof(TPage)) as TPage
+ ?? throw new NavigationException($"{typeof(TPage)} page not found.");
+ }
+}
diff --git a/src/Wpf.Ui.Abstractions/Wpf.Ui.Abstractions.csproj b/src/Wpf.Ui.Abstractions/Wpf.Ui.Abstractions.csproj
new file mode 100644
index 000000000..462d23eb9
--- /dev/null
+++ b/src/Wpf.Ui.Abstractions/Wpf.Ui.Abstractions.csproj
@@ -0,0 +1,22 @@
+
+
+
+ WPF-UI.Abstractions
+ netstandard2.0;netstandard2.1;net462;net6.0;net8.0
+ true
+ Abstractions for the WPF UI.
+ $(CommonTags);abstractions;standard
+
+
+
+
+ all
+ build; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
diff --git a/src/Wpf.Ui.Demo.Mvvm/AssemblyInfo.cs b/src/Wpf.Ui.Demo.Mvvm/AssemblyInfo.cs
deleted file mode 100644
index eaf149880..000000000
--- a/src/Wpf.Ui.Demo.Mvvm/AssemblyInfo.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-// This Source Code Form is subject to the terms of the MIT License.
-// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
-// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
-// All Rights Reserved.
-
-[assembly: ThemeInfo(
- ResourceDictionaryLocation.None, // Where theme specific resource dictionaries are located (used if a resource is not found in the page, or application resource dictionaries)
- ResourceDictionaryLocation.SourceAssembly // Where the generic resource dictionary is located (used if a resource is not found in the page, app, or any theme specific resource dictionaries)
-)]
diff --git a/src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs b/src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs
deleted file mode 100644
index 1484a122e..000000000
--- a/src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// This Source Code Form is subject to the terms of the MIT License.
-// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
-// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
-// All Rights Reserved.
-
-namespace Wpf.Ui.Demo.Mvvm.Services;
-
-///
-/// Service that provides pages for navigation.
-///
-public class PageService : IPageService
-{
- ///
- /// Service which provides the instances of pages.
- ///
- private readonly IServiceProvider _serviceProvider;
-
- ///
- /// Initializes a new instance of the class and attaches the .
- ///
- public PageService(IServiceProvider serviceProvider)
- {
- _serviceProvider = serviceProvider;
- }
-
- ///
- public T? GetPage()
- where T : class
- {
- if (!typeof(FrameworkElement).IsAssignableFrom(typeof(T)))
- {
- throw new InvalidOperationException("The page should be a WPF control.");
- }
-
- return (T?)_serviceProvider.GetService(typeof(T));
- }
-
- ///
- public FrameworkElement? GetPage(Type pageType)
- {
- if (!typeof(FrameworkElement).IsAssignableFrom(pageType))
- {
- throw new InvalidOperationException("The page should be a WPF control.");
- }
-
- return _serviceProvider.GetService(pageType) as FrameworkElement;
- }
-}
diff --git a/src/Wpf.Ui.DependencyInjection/DependencyInjectionNavigationViewPageProvider.cs b/src/Wpf.Ui.DependencyInjection/DependencyInjectionNavigationViewPageProvider.cs
new file mode 100644
index 000000000..de5ef1927
--- /dev/null
+++ b/src/Wpf.Ui.DependencyInjection/DependencyInjectionNavigationViewPageProvider.cs
@@ -0,0 +1,21 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+using Wpf.Ui.Abstractions;
+
+namespace Wpf.Ui.DependencyInjection;
+
+///
+/// Service that provides pages for navigation.
+///
+public class DependencyInjectionNavigationViewPageProvider(IServiceProvider serviceProvider)
+ : INavigationViewPageProvider
+{
+ ///
+ public object? GetPage(Type pageType)
+ {
+ return serviceProvider.GetService(pageType);
+ }
+}
diff --git a/src/Wpf.Ui.DependencyInjection/GlobalUsings.cs b/src/Wpf.Ui.DependencyInjection/GlobalUsings.cs
new file mode 100644
index 000000000..bc3b69a4d
--- /dev/null
+++ b/src/Wpf.Ui.DependencyInjection/GlobalUsings.cs
@@ -0,0 +1,6 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+global using System;
diff --git a/src/Wpf.Ui.DependencyInjection/ServiceCollectionExtensions.cs b/src/Wpf.Ui.DependencyInjection/ServiceCollectionExtensions.cs
new file mode 100644
index 000000000..71a7be708
--- /dev/null
+++ b/src/Wpf.Ui.DependencyInjection/ServiceCollectionExtensions.cs
@@ -0,0 +1,31 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+using Microsoft.Extensions.DependencyInjection;
+using Wpf.Ui.Abstractions;
+
+namespace Wpf.Ui.DependencyInjection;
+
+///
+/// Provides extension methods for to support WPF UI navigation and services.
+///
+public static class ServiceCollectionExtensions
+{
+ ///
+ /// Adds the services necessary for page navigation within a WPF UI NavigationView.
+ ///
+ /// The to add the services to.
+ /// The so that additional calls can be chained.
+
+ public static IServiceCollection AddNavigationViewPageProvider(this IServiceCollection services)
+ {
+ _ = services.AddSingleton<
+ INavigationViewPageProvider,
+ DependencyInjectionNavigationViewPageProvider
+ >();
+
+ return services;
+ }
+}
diff --git a/src/Wpf.Ui.DependencyInjection/Wpf.Ui.DependencyInjection.csproj b/src/Wpf.Ui.DependencyInjection/Wpf.Ui.DependencyInjection.csproj
new file mode 100644
index 000000000..77003a0ac
--- /dev/null
+++ b/src/Wpf.Ui.DependencyInjection/Wpf.Ui.DependencyInjection.csproj
@@ -0,0 +1,27 @@
+
+
+
+ WPF-UI.DependencyInjection
+ netstandard2.0;netstandard2.1;net462;net6.0;net8.0
+ true
+ Dependency injection for the WPF UI.
+ $(CommonTags);dependency;injection;abstractions;standard
+
+
+
+
+
+ all
+ build; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Wpf.Ui.FontMapper/GitTag.cs b/src/Wpf.Ui.FontMapper/GitTag.cs
index a31b1015d..e4a47f0a4 100644
--- a/src/Wpf.Ui.FontMapper/GitTag.cs
+++ b/src/Wpf.Ui.FontMapper/GitTag.cs
@@ -1,4 +1,4 @@
-// This Source Code Form is subject to the terms of the MIT License.
+// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
diff --git a/src/Wpf.Ui.FontMapper/GlobalUsings.cs b/src/Wpf.Ui.FontMapper/GlobalUsings.cs
new file mode 100644
index 000000000..93e017b6b
--- /dev/null
+++ b/src/Wpf.Ui.FontMapper/GlobalUsings.cs
@@ -0,0 +1,11 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+global using System;
+global using System.Collections.Generic;
+global using System.IO;
+global using System.Linq;
+global using System.Text;
+global using System.Threading.Tasks;
diff --git a/src/Wpf.Ui.FontMapper/Program.cs b/src/Wpf.Ui.FontMapper/Program.cs
index f62985b21..31ad36578 100644
--- a/src/Wpf.Ui.FontMapper/Program.cs
+++ b/src/Wpf.Ui.FontMapper/Program.cs
@@ -3,8 +3,8 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
+using System.Net.Http;
using System.Net.Http.Json;
-using System.Text;
using Wpf.Ui.FontMapper;
Console.WriteLine("Fluent System Icons Mapper");
diff --git a/src/Wpf.Ui.Gallery/App.xaml.cs b/src/Wpf.Ui.Gallery/App.xaml.cs
index 9022a6ff5..6ded57e72 100644
--- a/src/Wpf.Ui.Gallery/App.xaml.cs
+++ b/src/Wpf.Ui.Gallery/App.xaml.cs
@@ -3,7 +3,10 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
+using Lepo.i18n.DependencyInjection;
+using Wpf.Ui.DependencyInjection;
using Wpf.Ui.Gallery.DependencyModel;
+using Wpf.Ui.Gallery.Resources;
using Wpf.Ui.Gallery.Services;
using Wpf.Ui.Gallery.Services.Contracts;
using Wpf.Ui.Gallery.ViewModels.Pages;
@@ -28,6 +31,8 @@ public partial class App
.ConfigureServices(
(_1, services) =>
{
+ _ = services.AddNavigationViewPageProvider();
+
// App Host
_ = services.AddHostedService();
@@ -53,6 +58,11 @@ public partial class App
"Wpf.Ui.Gallery.ViewModels",
GalleryAssembly.Asssembly
);
+
+ _ = services.AddStringLocalizer(b =>
+ {
+ b.FromResource(new("pl-PL"));
+ });
}
)
.Build();
diff --git a/src/Wpf.Ui.Gallery/ControlsLookup/GalleryPageAttribute.cs b/src/Wpf.Ui.Gallery/ControlsLookup/GalleryPageAttribute.cs
index a201ca741..e1596b0c6 100644
--- a/src/Wpf.Ui.Gallery/ControlsLookup/GalleryPageAttribute.cs
+++ b/src/Wpf.Ui.Gallery/ControlsLookup/GalleryPageAttribute.cs
@@ -8,15 +8,9 @@
namespace Wpf.Ui.Gallery.ControlsLookup;
[AttributeUsage(AttributeTargets.Class)]
-internal class GalleryPageAttribute : Attribute
+internal sealed class GalleryPageAttribute(string description, SymbolRegular icon) : Attribute
{
- public string Description { get; }
+ public string Description { get; } = description;
- public SymbolRegular Icon { get; }
-
- public GalleryPageAttribute(string description, SymbolRegular icon)
- {
- Description = description;
- Icon = icon;
- }
+ public SymbolRegular Icon { get; } = icon;
}
diff --git a/src/Wpf.Ui.Gallery/DependencyModel/ServiceCollectionExtensions.cs b/src/Wpf.Ui.Gallery/DependencyModel/ServiceCollectionExtensions.cs
index 4ff90aee8..41bbfadef 100644
--- a/src/Wpf.Ui.Gallery/DependencyModel/ServiceCollectionExtensions.cs
+++ b/src/Wpf.Ui.Gallery/DependencyModel/ServiceCollectionExtensions.cs
@@ -3,6 +3,8 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
+using Wpf.Ui.Gallery.ViewModels;
+
namespace Wpf.Ui.Gallery.DependencyModel;
internal static class ServiceCollectionExtensions
@@ -26,6 +28,11 @@ params Assembly[] assemblies
{
if (services.All(x => x.ServiceType != type))
{
+ if (type == typeof(ViewModel))
+ {
+ continue;
+ }
+
_ = services.AddTransient(type);
}
}
diff --git a/src/Wpf.Ui.Gallery/Usings.cs b/src/Wpf.Ui.Gallery/GlobalUsings.cs
similarity index 96%
rename from src/Wpf.Ui.Gallery/Usings.cs
rename to src/Wpf.Ui.Gallery/GlobalUsings.cs
index bb18e5018..c26fd1471 100644
--- a/src/Wpf.Ui.Gallery/Usings.cs
+++ b/src/Wpf.Ui.Gallery/GlobalUsings.cs
@@ -25,3 +25,4 @@
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
+global using Wpf.Ui.Abstractions.Controls;
diff --git a/src/Wpf.Ui.Gallery/Resources/Translations.cs b/src/Wpf.Ui.Gallery/Resources/Translations.cs
new file mode 100644
index 000000000..273c6012d
--- /dev/null
+++ b/src/Wpf.Ui.Gallery/Resources/Translations.cs
@@ -0,0 +1,8 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+namespace Wpf.Ui.Gallery.Resources;
+
+public partial class Translations;
diff --git a/src/Wpf.Ui.Gallery/Resources/Translations.pl-PL.Designer.cs b/src/Wpf.Ui.Gallery/Resources/Translations.pl-PL.Designer.cs
new file mode 100644
index 000000000..4c5543244
--- /dev/null
+++ b/src/Wpf.Ui.Gallery/Resources/Translations.pl-PL.Designer.cs
@@ -0,0 +1,80 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Wpf.Ui.Gallery.Resources {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Translations_pl_PL {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Translations_pl_PL() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Wpf.Ui.Gallery.Resources.Translations.pl-PL", typeof(Translations_pl_PL).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Szukaj.
+ ///
+ internal static string Search {
+ get {
+ return ResourceManager.GetString("Search", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to WPF UI Galeria.
+ ///
+ internal static string WPF_UI_Gallery {
+ get {
+ return ResourceManager.GetString("WPF UI Gallery", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/src/Wpf.Ui.Gallery/Resources/Translations.pl-PL.resx b/src/Wpf.Ui.Gallery/Resources/Translations.pl-PL.resx
new file mode 100644
index 000000000..f24f175a5
--- /dev/null
+++ b/src/Wpf.Ui.Gallery/Resources/Translations.pl-PL.resx
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Szukaj
+
+
+ WPF UI Galeria
+
+
\ No newline at end of file
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/AllControlsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/AllControlsViewModel.cs
index b42fa064b..8aae53d39 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/AllControlsViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/AllControlsViewModel.cs
@@ -8,7 +8,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages;
-public partial class AllControlsViewModel : ObservableObject
+public partial class AllControlsViewModel : ViewModel
{
[ObservableProperty]
private ICollection _navigationCards = new ObservableCollection(
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/AnchorViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/AnchorViewModel.cs
index f836fa614..1e3a12ec5 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/AnchorViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/AnchorViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class AnchorViewModel : ObservableObject
+public partial class AnchorViewModel : ViewModel
{
[ObservableProperty]
private bool _isAnchorEnabled = true;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/BasicInputViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/BasicInputViewModel.cs
index 0fbe0b6aa..01e60cf6d 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/BasicInputViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/BasicInputViewModel.cs
@@ -9,7 +9,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class BasicInputViewModel : ObservableObject
+public partial class BasicInputViewModel : ViewModel
{
[ObservableProperty]
private ICollection _navigationCards = new ObservableCollection(
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ButtonViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ButtonViewModel.cs
index 517208cd6..21b8ac12f 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ButtonViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ButtonViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class ButtonViewModel : ObservableObject
+public partial class ButtonViewModel : ViewModel
{
[ObservableProperty]
private bool _isSimpleButtonEnabled = true;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/CheckBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/CheckBoxViewModel.cs
index 82de7553c..ab53742e4 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/CheckBoxViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/CheckBoxViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class CheckBoxViewModel : ObservableObject
+public partial class CheckBoxViewModel : ViewModel
{
[ObservableProperty]
private bool? _selectAllCheckBoxChecked = null;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ComboBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ComboBoxViewModel.cs
index f6922aad1..d2a941272 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ComboBoxViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ComboBoxViewModel.cs
@@ -5,7 +5,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class ComboBoxViewModel : ObservableObject
+public partial class ComboBoxViewModel : ViewModel
{
[ObservableProperty]
private ObservableCollection _comboBoxFontFamilies =
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/DropDownButtonViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/DropDownButtonViewModel.cs
index 50c132a15..4faf3293d 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/DropDownButtonViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/DropDownButtonViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class DropDownButtonViewModel : ObservableObject { }
+public partial class DropDownButtonViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/HyperlinkButtonViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/HyperlinkButtonViewModel.cs
index 4152768a5..2f6669d6a 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/HyperlinkButtonViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/HyperlinkButtonViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class HyperlinkButtonViewModel : ObservableObject
+public partial class HyperlinkButtonViewModel : ViewModel
{
[ObservableProperty]
private bool _isHyperlinkEnabled = true;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RadioButtonViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RadioButtonViewModel.cs
index 4bf2bb27e..0f8ede55c 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RadioButtonViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RadioButtonViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class RadioButtonViewModel : ObservableObject
+public partial class RadioButtonViewModel : ViewModel
{
[ObservableProperty]
private bool _isRadioButtonEnabled = true;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RatingViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RatingViewModel.cs
index ade563762..8df95640c 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RatingViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/RatingViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class RatingViewModel : ObservableObject
+public partial class RatingViewModel : ViewModel
{
[ObservableProperty]
private bool _isFirstRatingEnabled = true;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/SliderViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/SliderViewModel.cs
index c4142e7c8..f3214a91b 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/SliderViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/SliderViewModel.cs
@@ -5,7 +5,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class SliderViewModel : ObservableObject
+public partial class SliderViewModel : ViewModel
{
[ObservableProperty]
private int _simpleSliderValue = 0;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/SplitButtonViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/SplitButtonViewModel.cs
index 5e189cf8b..7ea893c78 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/SplitButtonViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/SplitButtonViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class SplitButtonViewModel : ObservableObject { }
+public partial class SplitButtonViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ThumbRateViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ThumbRateViewModel.cs
index addd3339a..1253e33fd 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ThumbRateViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ThumbRateViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class ThumbRateViewModel : ObservableObject
+public partial class ThumbRateViewModel : ViewModel
{
[ObservableProperty]
private string _thumRateStateText = "Liked";
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleButtonViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleButtonViewModel.cs
index 35e216ae0..c73c965db 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleButtonViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleButtonViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class ToggleButtonViewModel : ObservableObject
+public partial class ToggleButtonViewModel : ViewModel
{
[ObservableProperty]
private bool _isToggleButtonEnabled = true;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleSwitchViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleSwitchViewModel.cs
index 57f3d5dd7..2ed86672c 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleSwitchViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/BasicInput/ToggleSwitchViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.BasicInput;
-public partial class ToggleSwitchViewModel : ObservableObject
+public partial class ToggleSwitchViewModel : ViewModel
{
[ObservableProperty]
private bool _isToggleSwitchEnabled = true;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/CollectionsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/CollectionsViewModel.cs
index ac2b78c44..823ff479b 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/CollectionsViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/CollectionsViewModel.cs
@@ -9,7 +9,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Collections;
-public partial class CollectionsViewModel : ObservableObject
+public partial class CollectionsViewModel : ViewModel
{
[ObservableProperty]
private ICollection _navigationCards = new ObservableCollection(
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs
index 0622a7f67..cef593de8 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/DataGridViewModel.cs
@@ -7,15 +7,10 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Collections;
-public partial class DataGridViewModel : ObservableObject
+public partial class DataGridViewModel : ViewModel
{
[ObservableProperty]
- private ObservableCollection _productsCollection;
-
- public DataGridViewModel()
- {
- _productsCollection = GenerateProducts();
- }
+ private ObservableCollection _productsCollection = GenerateProducts();
private static ObservableCollection GenerateProducts()
{
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListBoxViewModel.cs
index 968dd5084..78ff39e9b 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListBoxViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListBoxViewModel.cs
@@ -5,13 +5,15 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Collections;
-public partial class ListBoxViewModel : ObservableObject
+public partial class ListBoxViewModel : ViewModel
{
[ObservableProperty]
- private ObservableCollection _listBoxItems;
-
- public ListBoxViewModel()
- {
- _listBoxItems = ["Arial", "Comic Sans MS", "Courier New", "Segoe UI", "Times New Roman"];
- }
+ private ObservableCollection _listBoxItems =
+ [
+ "Arial",
+ "Comic Sans MS",
+ "Courier New",
+ "Segoe UI",
+ "Times New Roman"
+ ];
}
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListViewViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListViewViewModel.cs
index b12c98bf5..fb6a222e5 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListViewViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/ListViewViewModel.cs
@@ -8,7 +8,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Collections;
-public partial class ListViewViewModel : ObservableObject
+public partial class ListViewViewModel : ViewModel
{
private int _listViewSelectionModeComboBoxSelectedIndex = 0;
@@ -26,12 +26,7 @@ public int ListViewSelectionModeComboBoxSelectedIndex
private SelectionMode _listViewSelectionMode = SelectionMode.Single;
[ObservableProperty]
- private ObservableCollection _basicListViewItems;
-
- public ListViewViewModel()
- {
- _basicListViewItems = GeneratePersons();
- }
+ private ObservableCollection _basicListViewItems = GeneratePersons();
private static ObservableCollection GeneratePersons()
{
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/TreeListViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/TreeListViewModel.cs
index 31a630050..a2c224309 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/TreeListViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/TreeListViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Collections;
-public partial class TreeListViewModel : ObservableObject { }
+public partial class TreeListViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/TreeViewViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/TreeViewViewModel.cs
index a4ecfe629..7ac2971af 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/TreeViewViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Collections/TreeViewViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Collections;
-public partial class TreeViewViewModel : ObservableObject { }
+public partial class TreeViewViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DashboardViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DashboardViewModel.cs
index 60d3d3e00..7e613a4af 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DashboardViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DashboardViewModel.cs
@@ -7,15 +7,8 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages;
-public partial class DashboardViewModel : ObservableObject
+public partial class DashboardViewModel(INavigationService navigationService) : ViewModel
{
- private readonly INavigationService _navigationService;
-
- public DashboardViewModel(INavigationService navigationService)
- {
- _navigationService = navigationService;
- }
-
[RelayCommand]
private void OnCardClick(string parameter)
{
@@ -31,6 +24,6 @@ private void OnCardClick(string parameter)
return;
}
- _ = _navigationService.Navigate(pageType);
+ _ = navigationService.Navigate(pageType);
}
}
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/CalendarDatePickerViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/CalendarDatePickerViewModel.cs
index 2a70e5f3d..270e413a7 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/CalendarDatePickerViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/CalendarDatePickerViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DateAndTime;
-public partial class CalendarDatePickerViewModel : ObservableObject { }
+public partial class CalendarDatePickerViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/CalendarViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/CalendarViewModel.cs
index 2fc89d297..35a2c6cdd 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/CalendarViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/CalendarViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DateAndTime;
-public partial class CalendarViewModel : ObservableObject { }
+public partial class CalendarViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/DateAndTimeViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/DateAndTimeViewModel.cs
index c49bd9cbd..166dd1870 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/DateAndTimeViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/DateAndTimeViewModel.cs
@@ -9,7 +9,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DateAndTime;
-public partial class DateAndTimeViewModel : ObservableObject
+public partial class DateAndTimeViewModel : ViewModel
{
[ObservableProperty]
private ICollection _navigationCards = new ObservableCollection(
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/DatePickerViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/DatePickerViewModel.cs
index abc8ce110..aaab6ce6c 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/DatePickerViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/DatePickerViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DateAndTime;
-public partial class DatePickerViewModel : ObservableObject { }
+public partial class DatePickerViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/TimePickerViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/TimePickerViewModel.cs
index 0cd7c902d..9eda433b1 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/TimePickerViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DateAndTime/TimePickerViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DateAndTime;
-public partial class TimePickerViewModel : ObservableObject { }
+public partial class TimePickerViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/ColorsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/ColorsViewModel.cs
index 8fdadc0ba..d3e551289 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/ColorsViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/ColorsViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DesignGuidance;
-public partial class ColorsViewModel : ObservableObject { }
+public partial class ColorsViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/IconsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/IconsViewModel.cs
index 91697eef6..51a3a97de 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/IconsViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/IconsViewModel.cs
@@ -9,7 +9,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DesignGuidance;
-public partial class IconsViewModel : ObservableObject, INavigationAware
+public partial class IconsViewModel : ViewModel
{
private int _selectedIconId = 0;
@@ -91,10 +91,6 @@ public IconsViewModel()
});
}
- public void OnNavigatedTo() { }
-
- public void OnNavigatedFrom() { }
-
[RelayCommand]
public void OnIconSelected(int parameter)
{
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/TypographyViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/TypographyViewModel.cs
index be9d040e1..a52880457 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/TypographyViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DesignGuidance/TypographyViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DesignGuidance;
-public partial class TypographyViewModel : ObservableObject { }
+public partial class TypographyViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/ContentDialogViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/ContentDialogViewModel.cs
index 1df7fd7a9..66756260d 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/ContentDialogViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/ContentDialogViewModel.cs
@@ -9,22 +9,15 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts;
-public partial class ContentDialogViewModel : ObservableObject
+public partial class ContentDialogViewModel(IContentDialogService contentDialogService) : ViewModel
{
- private readonly IContentDialogService _contentDialogService;
-
- public ContentDialogViewModel(IContentDialogService contentDialogService)
- {
- _contentDialogService = contentDialogService;
- }
-
[ObservableProperty]
private string _dialogResultText = string.Empty;
[RelayCommand]
private async Task OnShowDialog(object content)
{
- ContentDialogResult result = await _contentDialogService.ShowSimpleDialogAsync(
+ ContentDialogResult result = await contentDialogService.ShowSimpleDialogAsync(
new SimpleContentDialogCreateOptions()
{
Title = "Save your work?",
@@ -46,7 +39,7 @@ private async Task OnShowDialog(object content)
[RelayCommand]
private async Task OnShowSignInContentDialog()
{
- var termsOfUseContentDialog = new TermsOfUseContentDialog(_contentDialogService.GetDialogHost());
+ var termsOfUseContentDialog = new TermsOfUseContentDialog(contentDialogService.GetDialogHost());
_ = await termsOfUseContentDialog.ShowAsync();
}
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/DialogsAndFlyoutsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/DialogsAndFlyoutsViewModel.cs
index 5496721df..892da7468 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/DialogsAndFlyoutsViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/DialogsAndFlyoutsViewModel.cs
@@ -9,7 +9,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts;
-public partial class DialogsAndFlyoutsViewModel : ObservableObject
+public partial class DialogsAndFlyoutsViewModel : ViewModel
{
[ObservableProperty]
private ICollection _navigationCards = new ObservableCollection(
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/FlyoutViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/FlyoutViewModel.cs
index c72c3be78..6f798d5a1 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/FlyoutViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/FlyoutViewModel.cs
@@ -5,7 +5,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts;
-public partial class FlyoutViewModel : ObservableObject
+public partial class FlyoutViewModel : ViewModel
{
[ObservableProperty]
private bool _isFlyoutOpen = false;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/MessageBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/MessageBoxViewModel.cs
index 7a527c79e..940d50429 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/MessageBoxViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/MessageBoxViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts;
-public partial class MessageBoxViewModel : ObservableObject
+public partial class MessageBoxViewModel : ViewModel
{
[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "relay command")]
[RelayCommand]
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/SnackbarViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/SnackbarViewModel.cs
index 8279746ff..7b8db4ece 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/SnackbarViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/DialogsAndFlyouts/SnackbarViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts;
-public partial class SnackbarViewModel(ISnackbarService snackbarService) : ObservableObject
+public partial class SnackbarViewModel(ISnackbarService snackbarService) : ViewModel
{
private ControlAppearance _snackbarAppearance = ControlAppearance.Secondary;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/CardActionViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/CardActionViewModel.cs
index a2db63988..1fac5dd3d 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/CardActionViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/CardActionViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Layout;
-public partial class CardActionViewModel : ObservableObject { }
+public partial class CardActionViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/CardControlViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/CardControlViewModel.cs
index 216b6f369..1ecff8842 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/CardControlViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/CardControlViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Layout;
-public partial class CardControlViewModel : ObservableObject { }
+public partial class CardControlViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/ExpanderViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/ExpanderViewModel.cs
index 5bb9e42d0..a815cd09a 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/ExpanderViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/ExpanderViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Layout;
-public partial class ExpanderViewModel : ObservableObject { }
+public partial class ExpanderViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/LayoutViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/LayoutViewModel.cs
index a046d5665..975aff3be 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/LayoutViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Layout/LayoutViewModel.cs
@@ -9,7 +9,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Layout;
-public partial class LayoutViewModel : ObservableObject
+public partial class LayoutViewModel : ViewModel
{
[ObservableProperty]
private ICollection _navigationCards = new ObservableCollection(
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/CanvasViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/CanvasViewModel.cs
index 55ea703d7..ab429e686 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/CanvasViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/CanvasViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Media;
-public partial class CanvasViewModel : ObservableObject { }
+public partial class CanvasViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/ImageViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/ImageViewModel.cs
index 5acb9a60a..5d2b166e8 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/ImageViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/ImageViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Media;
-public partial class ImageViewModel : ObservableObject { }
+public partial class ImageViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/MediaViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/MediaViewModel.cs
index f5c08dad0..527a880e7 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/MediaViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/MediaViewModel.cs
@@ -9,7 +9,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Media;
-public partial class MediaViewModel : ObservableObject
+public partial class MediaViewModel : ViewModel
{
[ObservableProperty]
private ICollection _navigationCards = new ObservableCollection(
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/WebBrowserViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/WebBrowserViewModel.cs
index 6915162df..6a7090b1a 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/WebBrowserViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/WebBrowserViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Media;
-public partial class WebBrowserViewModel : ObservableObject { }
+public partial class WebBrowserViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/WebViewViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/WebViewViewModel.cs
index 84dc06d76..0aee24dab 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/WebViewViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Media/WebViewViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Media;
-public partial class WebViewViewModel : ObservableObject { }
+public partial class WebViewViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/BreadcrumbBarViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/BreadcrumbBarViewModel.cs
index 67c75fbf4..9bf739c56 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/BreadcrumbBarViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/BreadcrumbBarViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Navigation;
-public partial class BreadcrumbBarViewModel : ObservableObject
+public partial class BreadcrumbBarViewModel : ViewModel
{
private readonly Folder[] _baseFoldersCollection =
[
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/MenuViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/MenuViewModel.cs
index 91b5e88da..caab2d093 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/MenuViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/MenuViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Navigation;
-public partial class MenuViewModel : ObservableObject { }
+public partial class MenuViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/NavigationViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/NavigationViewModel.cs
index e71e83dcb..cfb96f614 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/NavigationViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/NavigationViewModel.cs
@@ -9,7 +9,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Navigation;
-public partial class NavigationViewModel : ObservableObject
+public partial class NavigationViewModel : ViewModel
{
[ObservableProperty]
private ICollection _navigationCards = new ObservableCollection(
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/NavigationViewViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/NavigationViewViewModel.cs
index b995686d1..e46369ce5 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/NavigationViewViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/NavigationViewViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Navigation;
-public partial class NavigationViewViewModel : ObservableObject { }
+public partial class NavigationViewViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/TabControlViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/TabControlViewModel.cs
index e08cba718..cdb2979d8 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/TabControlViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/TabControlViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Navigation;
-public partial class TabControlViewModel : ObservableObject { }
+public partial class TabControlViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/TabViewViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/TabViewViewModel.cs
index 0b0521b52..ed0253452 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/TabViewViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Navigation/TabViewViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Navigation;
-public partial class TabViewViewModel : ObservableObject { }
+public partial class TabViewViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/ClipboardViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/ClipboardViewModel.cs
index 3d7cca1e3..1ef8495c8 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/ClipboardViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/ClipboardViewModel.cs
@@ -5,7 +5,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.OpSystem;
-public partial class ClipboardViewModel : ObservableObject
+public partial class ClipboardViewModel : ViewModel
{
[ObservableProperty]
private string _textToCopy = "This text will be copied to the clipboard.";
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/FilePickerViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/FilePickerViewModel.cs
index 92974f0e9..5414ae842 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/FilePickerViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/FilePickerViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.OpSystem;
-public partial class FilePickerViewModel : ObservableObject
+public partial class FilePickerViewModel : ViewModel
{
[ObservableProperty]
private Visibility _openedFilePathVisibility = Visibility.Collapsed;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/OpSystemViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/OpSystemViewModel.cs
index c291816b2..d52cd68fb 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/OpSystemViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/OpSystem/OpSystemViewModel.cs
@@ -9,7 +9,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.OpSystem;
-public partial class OpSystemViewModel : ObservableObject
+public partial class OpSystemViewModel : ViewModel
{
[ObservableProperty]
private ICollection _navigationCards = new ObservableCollection(
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs
index 5c679b4be..b3c693d58 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/SettingsViewModel.cs
@@ -9,10 +9,8 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages;
-public sealed partial class SettingsViewModel : ObservableObject, INavigationAware
+public sealed partial class SettingsViewModel(INavigationService navigationService) : ViewModel
{
- private readonly INavigationService _navigationService;
-
private bool _isInitialized = false;
[ObservableProperty]
@@ -25,12 +23,7 @@ public sealed partial class SettingsViewModel : ObservableObject, INavigationAwa
private NavigationViewPaneDisplayMode _currentApplicationNavigationStyle =
NavigationViewPaneDisplayMode.Left;
- public SettingsViewModel(INavigationService navigationService)
- {
- _navigationService = navigationService;
- }
-
- public void OnNavigatedTo()
+ public override void OnNavigatedTo()
{
if (!_isInitialized)
{
@@ -38,8 +31,6 @@ public void OnNavigatedTo()
}
}
- public void OnNavigatedFrom() { }
-
partial void OnCurrentApplicationThemeChanged(ApplicationTheme oldValue, ApplicationTheme newValue)
{
ApplicationThemeManager.Apply(newValue);
@@ -50,7 +41,7 @@ partial void OnCurrentApplicationNavigationStyleChanged(
NavigationViewPaneDisplayMode newValue
)
{
- _ = _navigationService.SetPaneDisplayMode(newValue);
+ _ = navigationService.SetPaneDisplayMode(newValue);
}
private void InitializeViewModel()
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBadgeViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBadgeViewModel.cs
index 6d5885c0b..309f99cd0 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBadgeViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBadgeViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.StatusAndInfo;
-public partial class InfoBadgeViewModel : ObservableObject
+public partial class InfoBadgeViewModel : ViewModel
{
[ObservableProperty]
private InfoBadgeSeverity _infoBadgeSeverity = InfoBadgeSeverity.Attention;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBarViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBarViewModel.cs
index c420d64a1..0ffae8af4 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBarViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/InfoBarViewModel.cs
@@ -7,7 +7,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.StatusAndInfo;
-public partial class InfoBarViewModel : ObservableObject
+public partial class InfoBarViewModel : ViewModel
{
[ObservableProperty]
private bool _isShortInfoBarOpened = true;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/ProgressBarViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/ProgressBarViewModel.cs
index de6d7cae9..202ff974f 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/ProgressBarViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/ProgressBarViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.StatusAndInfo;
-public partial class ProgressBarViewModel : ObservableObject { }
+public partial class ProgressBarViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/ProgressRingViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/ProgressRingViewModel.cs
index 99947d80a..fe5271f23 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/ProgressRingViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/ProgressRingViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.StatusAndInfo;
-public partial class ProgressRingViewModel : ObservableObject { }
+public partial class ProgressRingViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/StatusAndInfoViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/StatusAndInfoViewModel.cs
index c3bc9e8af..1fafb8ddc 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/StatusAndInfoViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/StatusAndInfoViewModel.cs
@@ -9,7 +9,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.StatusAndInfo;
-public partial class StatusAndInfoViewModel : ObservableObject
+public partial class StatusAndInfoViewModel : ViewModel
{
[ObservableProperty]
private ICollection _navigationCards = new ObservableCollection(
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/ToolTipViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/ToolTipViewModel.cs
index bbd848216..b706e4329 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/ToolTipViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/StatusAndInfo/ToolTipViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.StatusAndInfo;
-public partial class ToolTipViewModel : ObservableObject { }
+public partial class ToolTipViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/AutoSuggestBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/AutoSuggestBoxViewModel.cs
index 4842007d4..932cc4f20 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/AutoSuggestBoxViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/AutoSuggestBoxViewModel.cs
@@ -5,7 +5,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Text;
-public partial class AutoSuggestBoxViewModel : ObservableObject
+public partial class AutoSuggestBoxViewModel : ViewModel
{
[ObservableProperty]
private List _autoSuggestBoxSuggestions =
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/LabelViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/LabelViewModel.cs
index 897f59184..ac8f086d6 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/LabelViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/LabelViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Text;
-public partial class LabelViewModel : ObservableObject { }
+public partial class LabelViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/NumberBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/NumberBoxViewModel.cs
index c39fc7f40..2203f05bc 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/NumberBoxViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/NumberBoxViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Text;
-public partial class NumberBoxViewModel : ObservableObject { }
+public partial class NumberBoxViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/PasswordBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/PasswordBoxViewModel.cs
index 17949e1f0..cb6bdea9c 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/PasswordBoxViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/PasswordBoxViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Text;
-public partial class PasswordBoxViewModel : ObservableObject { }
+public partial class PasswordBoxViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/RichTextBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/RichTextBoxViewModel.cs
index 423af0ef1..7a40cc12e 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/RichTextBoxViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/RichTextBoxViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Text;
-public partial class RichTextBoxViewModel : ObservableObject { }
+public partial class RichTextBoxViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/TextBlockViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/TextBlockViewModel.cs
index 55a784a6e..849b86adb 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/TextBlockViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/TextBlockViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Text;
-public partial class TextBlockViewModel : ObservableObject { }
+public partial class TextBlockViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/TextBoxViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/TextBoxViewModel.cs
index 24f490b85..4a54d5d1c 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/TextBoxViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/TextBoxViewModel.cs
@@ -5,4 +5,4 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Text;
-public partial class TextBoxViewModel : ObservableObject { }
+public partial class TextBoxViewModel : ViewModel;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/TextViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/TextViewModel.cs
index 96f1144a3..f2b533ae2 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/TextViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Text/TextViewModel.cs
@@ -1,4 +1,4 @@
-// This Source Code Form is subject to the terms of the MIT License.
+// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
@@ -9,7 +9,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Text;
-public partial class TextViewModel : ObservableObject
+public partial class TextViewModel : ViewModel
{
[ObservableProperty]
private ICollection _navigationCards = new ObservableCollection(
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Pages/Windows/WindowsViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Pages/Windows/WindowsViewModel.cs
index 742e8beae..94a161b52 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Pages/Windows/WindowsViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Pages/Windows/WindowsViewModel.cs
@@ -10,7 +10,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Pages.Windows;
-public partial class WindowsViewModel(WindowsProviderService windowsProviderService) : ObservableObject
+public partial class WindowsViewModel(WindowsProviderService windowsProviderService) : ViewModel
{
[ObservableProperty]
private WindowCard[] _windowCards =
diff --git a/src/Wpf.Ui.Gallery/ViewModels/ViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/ViewModel.cs
new file mode 100644
index 000000000..dcb66a09f
--- /dev/null
+++ b/src/Wpf.Ui.Gallery/ViewModels/ViewModel.cs
@@ -0,0 +1,53 @@
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
+// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
+// All Rights Reserved.
+
+namespace Wpf.Ui.Gallery.ViewModels;
+
+public abstract partial class ViewModel : ObservableObject, INavigationAware
+{
+ ///
+ public virtual async Task OnNavigatedToAsync()
+ {
+ using CancellationTokenSource cts = new();
+
+ await DispatchAsync(OnNavigatedTo, cts.Token);
+ }
+
+ ///
+ /// Handles the event that is fired after the component is navigated to.
+ ///
+ // ReSharper disable once MemberCanBeProtected.Global
+ public virtual void OnNavigatedTo() { }
+
+ ///
+ public virtual async Task OnNavigatedFromAsync()
+ {
+ using CancellationTokenSource cts = new();
+
+ await DispatchAsync(OnNavigatedFrom, cts.Token);
+ }
+
+ ///
+ /// Handles the event that is fired before the component is navigated from.
+ ///
+ // ReSharper disable once MemberCanBeProtected.Global
+ public virtual void OnNavigatedFrom() { }
+
+ ///
+ /// Dispatches the specified action on the UI thread.
+ ///
+ /// The action to be dispatched.
+ /// A cancellation token that can be used to cancel the operation.
+ /// A task that represents the asynchronous operation.
+ protected static async Task DispatchAsync(Action action, CancellationToken cancellationToken)
+ {
+ if (cancellationToken.IsCancellationRequested)
+ {
+ return;
+ }
+
+ await Application.Current.Dispatcher.InvokeAsync(action);
+ }
+}
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Windows/EditorWindowViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Windows/EditorWindowViewModel.cs
index c7051b616..5b5b61f0c 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Windows/EditorWindowViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Windows/EditorWindowViewModel.cs
@@ -5,7 +5,7 @@
namespace Wpf.Ui.Gallery.ViewModels.Windows;
-public partial class EditorWindowViewModel : ObservableObject
+public partial class EditorWindowViewModel : ViewModel
{
[ObservableProperty]
private bool _isWordWrapEnbaled = false;
diff --git a/src/Wpf.Ui.Gallery/ViewModels/Windows/MainWindowViewModel.cs b/src/Wpf.Ui.Gallery/ViewModels/Windows/MainWindowViewModel.cs
index f49592479..c6101117e 100644
--- a/src/Wpf.Ui.Gallery/ViewModels/Windows/MainWindowViewModel.cs
+++ b/src/Wpf.Ui.Gallery/ViewModels/Windows/MainWindowViewModel.cs
@@ -5,7 +5,9 @@
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
+using Microsoft.Extensions.Localization;
using Wpf.Ui.Controls;
+using Wpf.Ui.Gallery.Resources;
using Wpf.Ui.Gallery.Views.Pages;
using Wpf.Ui.Gallery.Views.Pages.BasicInput;
using Wpf.Ui.Gallery.Views.Pages.Collections;
@@ -22,10 +24,10 @@
namespace Wpf.Ui.Gallery.ViewModels.Windows;
-public partial class MainWindowViewModel : ObservableObject
+public partial class MainWindowViewModel(IStringLocalizer localizer) : ViewModel
{
[ObservableProperty]
- private string _applicationTitle = "WPF UI Gallery";
+ private string _applicationTitle = localizer["WPF UI Gallery"];
[ObservableProperty]
private ObservableCollection
protected virtual void OpenMenu()
{
- System.Diagnostics.Debug.WriteLine(
+ Debug.WriteLine(
$"INFO | {typeof(TrayHandler)} invoked {nameof(OpenMenu)} method.",
"Wpf.Ui.NotifyIcon"
);
diff --git a/src/Wpf.Ui.Tray/Interop/Shell32.cs b/src/Wpf.Ui.Tray/Interop/Shell32.cs
index 65052b8e8..594e563e0 100644
--- a/src/Wpf.Ui.Tray/Interop/Shell32.cs
+++ b/src/Wpf.Ui.Tray/Interop/Shell32.cs
@@ -3,8 +3,6 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using System;
-using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Wpf.Ui.Tray.Interop;
diff --git a/src/Wpf.Ui.Tray/Interop/User32.cs b/src/Wpf.Ui.Tray/Interop/User32.cs
index 26e6829a5..1a1482e79 100644
--- a/src/Wpf.Ui.Tray/Interop/User32.cs
+++ b/src/Wpf.Ui.Tray/Interop/User32.cs
@@ -3,9 +3,6 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using System;
-using System.ComponentModel;
-using System.Runtime.InteropServices;
using System.Windows;
namespace Wpf.Ui.Tray.Interop;
diff --git a/src/Wpf.Ui.Tray/NotifyIconService.cs b/src/Wpf.Ui.Tray/NotifyIconService.cs
index 6b5ea4931..41b8a078e 100644
--- a/src/Wpf.Ui.Tray/NotifyIconService.cs
+++ b/src/Wpf.Ui.Tray/NotifyIconService.cs
@@ -3,7 +3,6 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
diff --git a/src/Wpf.Ui.Tray/RoutedNotifyIconEvent.cs b/src/Wpf.Ui.Tray/RoutedNotifyIconEvent.cs
index 7edbdc1eb..7f7b1377d 100644
--- a/src/Wpf.Ui.Tray/RoutedNotifyIconEvent.cs
+++ b/src/Wpf.Ui.Tray/RoutedNotifyIconEvent.cs
@@ -3,7 +3,6 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using System.Diagnostics.CodeAnalysis;
using System.Windows;
using Wpf.Ui.Tray.Controls;
diff --git a/src/Wpf.Ui.Tray/TrayData.cs b/src/Wpf.Ui.Tray/TrayData.cs
index a701b5f8c..d10d367c3 100644
--- a/src/Wpf.Ui.Tray/TrayData.cs
+++ b/src/Wpf.Ui.Tray/TrayData.cs
@@ -3,8 +3,6 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using System.Collections.Generic;
-
namespace Wpf.Ui.Tray;
///
diff --git a/src/Wpf.Ui.Tray/TrayHandler.cs b/src/Wpf.Ui.Tray/TrayHandler.cs
index 1648868cf..b2c2c5012 100644
--- a/src/Wpf.Ui.Tray/TrayHandler.cs
+++ b/src/Wpf.Ui.Tray/TrayHandler.cs
@@ -3,9 +3,6 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using System;
-using System.Windows.Interop;
-
namespace Wpf.Ui.Tray;
///
diff --git a/src/Wpf.Ui.Tray/TrayManager.cs b/src/Wpf.Ui.Tray/TrayManager.cs
index 161cf9223..2f1055429 100644
--- a/src/Wpf.Ui.Tray/TrayManager.cs
+++ b/src/Wpf.Ui.Tray/TrayManager.cs
@@ -3,9 +3,7 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
-using System;
using System.Windows;
-using System.Windows.Interop;
namespace Wpf.Ui.Tray;
diff --git a/src/Wpf.Ui.Tray/Wpf.Ui.Tray.csproj b/src/Wpf.Ui.Tray/Wpf.Ui.Tray.csproj
index e838be85a..d672b22f0 100644
--- a/src/Wpf.Ui.Tray/Wpf.Ui.Tray.csproj
+++ b/src/Wpf.Ui.Tray/Wpf.Ui.Tray.csproj
@@ -1,52 +1,26 @@
- $(PackagesCommonFrameworks)
- Library
- Properties
- Wpf.Ui.Tray
- Wpf.Ui.Tray
WPF-UI.Tray
- Wpf.Ui.Tray
- Wpf.Ui.Tray
- en-US
- true
- true
- true
- true
+ net462;net472;net481;net6.0-windows;net8.0-windows
+ true
Native tray menu icon support for WPF using the WPF UI library.
- wpf tray notify notifications icons icon notifyicon menu ui wpfui fluent design winui windows controls
-
-
-
- true
- true
- wpfui.png
+ $(CommonTags);tray;notifyicon;notify
+ true
-
-
-
-
-
+
-
+
-
- True
-
-
+
-
- true
-
-
@@ -55,36 +29,23 @@
-
- true
- snupkg
- true
- true
- false
- True
-
+
+
+
all
- runtime; build; native; contentfiles; analyzers; buildtransitive
+ build; analyzers
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
diff --git a/src/Wpf.Ui/Appearance/ApplicationAccentColorManager.cs b/src/Wpf.Ui/Appearance/ApplicationAccentColorManager.cs
index 141e918d5..e0fac34f3 100644
--- a/src/Wpf.Ui/Appearance/ApplicationAccentColorManager.cs
+++ b/src/Wpf.Ui/Appearance/ApplicationAccentColorManager.cs
@@ -41,7 +41,7 @@ public static Color SystemAccent
{
get
{
- var resource = UiApplication.Current.Resources["SystemAccentColor"];
+ object? resource = UiApplication.Current.Resources["SystemAccentColor"];
if (resource is Color color)
{
@@ -64,7 +64,7 @@ public static Color PrimaryAccent
{
get
{
- var resource = UiApplication.Current.Resources["SystemAccentColorPrimary"];
+ object? resource = UiApplication.Current.Resources["SystemAccentColorPrimary"];
if (resource is Color color)
{
@@ -87,7 +87,7 @@ public static Color SecondaryAccent
{
get
{
- var resource = UiApplication.Current.Resources["SystemAccentColorSecondary"];
+ object? resource = UiApplication.Current.Resources["SystemAccentColorSecondary"];
if (resource is Color color)
{
@@ -110,7 +110,7 @@ public static Color TertiaryAccent
{
get
{
- var resource = UiApplication.Current.Resources["SystemAccentColorTertiary"];
+ object? resource = UiApplication.Current.Resources["SystemAccentColorTertiary"];
if (resource is Color color)
{
diff --git a/src/Wpf.Ui/Appearance/ApplicationThemeManager.cs b/src/Wpf.Ui/Appearance/ApplicationThemeManager.cs
index 226be0fcc..df7f69435 100644
--- a/src/Wpf.Ui/Appearance/ApplicationThemeManager.cs
+++ b/src/Wpf.Ui/Appearance/ApplicationThemeManager.cs
@@ -82,9 +82,9 @@ public static void Apply(
return;
}
- var appDictionaries = new ResourceDictionaryManager(LibraryNamespace);
+ ResourceDictionaryManager appDictionaries = new(LibraryNamespace);
- var themeDictionaryName = "Light";
+ string themeDictionaryName = "Light";
switch (applicationTheme)
{
diff --git a/src/Wpf.Ui/Appearance/ObservedWindow.cs b/src/Wpf.Ui/Appearance/ObservedWindow.cs
index 36022049a..44e4c586c 100644
--- a/src/Wpf.Ui/Appearance/ObservedWindow.cs
+++ b/src/Wpf.Ui/Appearance/ObservedWindow.cs
@@ -7,10 +7,19 @@
namespace Wpf.Ui.Appearance;
+///
+/// Represents a window that is being observed for changes in appearance.
+///
internal class ObservedWindow
{
private readonly HwndSource _source;
+ ///
+ /// Initializes a new instance of the ObservedWindow class.
+ ///
+ /// The handle of the window.
+ /// The backdrop type of the window.
+ /// Indicates whether to update accents.
public ObservedWindow(IntPtr handle, WindowBackdropType backdrop, bool updateAccents)
{
Handle = handle;
@@ -18,21 +27,40 @@ public ObservedWindow(IntPtr handle, WindowBackdropType backdrop, bool updateAcc
UpdateAccents = updateAccents;
HasHook = false;
- var windowSource = HwndSource.FromHwnd(handle);
+ HwndSource? windowSource = HwndSource.FromHwnd(handle);
_source =
windowSource ?? throw new InvalidOperationException("Unable to determine the window source.");
}
+ ///
+ /// Gets the root visual of the window.
+ ///
public Window? RootVisual => (Window?)_source.RootVisual;
+ ///
+ /// Gets the handle of the window.
+ ///
public IntPtr Handle { get; }
+ ///
+ /// Gets the backdrop type of the window.
+ ///
public WindowBackdropType Backdrop { get; }
+ ///
+ /// Gets a value indicating whether to update accents.
+ ///
public bool UpdateAccents { get; }
+ ///
+ /// Gets a value indicating whether the window has a hook.
+ ///
public bool HasHook { get; private set; }
+ ///
+ /// Adds a hook to the window.
+ ///
+ /// The hook to add.
public void AddHook(HwndSourceHook hook)
{
_source.AddHook(hook);
@@ -40,6 +68,10 @@ public void AddHook(HwndSourceHook hook)
HasHook = true;
}
+ ///
+ /// Removes a hook from the window.
+ ///
+ /// The hook to remove.
public void RemoveHook(HwndSourceHook hook)
{
_source.RemoveHook(hook);
diff --git a/src/Wpf.Ui/AutomationPeers/CardControlAutomationPeer.cs b/src/Wpf.Ui/AutomationPeers/CardControlAutomationPeer.cs
index 318478cf8..185b09c78 100644
--- a/src/Wpf.Ui/AutomationPeers/CardControlAutomationPeer.cs
+++ b/src/Wpf.Ui/AutomationPeers/CardControlAutomationPeer.cs
@@ -9,16 +9,11 @@
namespace Wpf.Ui.AutomationPeers;
-internal class CardControlAutomationPeer : FrameworkElementAutomationPeer
+///
+/// Provides UI Automation peer for the CardControl.
+///
+internal class CardControlAutomationPeer(CardControl owner) : FrameworkElementAutomationPeer(owner)
{
- private readonly CardControl _owner;
-
- public CardControlAutomationPeer(CardControl owner)
- : base(owner)
- {
- _owner = owner;
- }
-
protected override string GetClassNameCore()
{
return "CardControl";
@@ -41,7 +36,7 @@ public override object GetPattern(PatternInterface patternInterface)
protected override AutomationPeer GetLabeledByCore()
{
- if (_owner.Header is UIElement element)
+ if (owner.Header is UIElement element)
{
return CreatePeerForElement(element);
}
@@ -55,15 +50,15 @@ protected override string GetNameCore()
if (result == string.Empty)
{
- result = AutomationProperties.GetName(_owner);
+ result = AutomationProperties.GetName(owner);
}
- if (result == string.Empty && _owner.Header is DependencyObject d)
+ if (result == string.Empty && owner.Header is DependencyObject d)
{
result = AutomationProperties.GetName(d);
}
- if (result == string.Empty && _owner.Header is string s)
+ if (result == string.Empty && owner.Header is string s)
{
result = s;
}
diff --git a/src/Wpf.Ui/Controls/ComboBox/ComboBox.xaml b/src/Wpf.Ui/Controls/ComboBox/ComboBox.xaml
index c33cebc9b..1eb250459 100644
--- a/src/Wpf.Ui/Controls/ComboBox/ComboBox.xaml
+++ b/src/Wpf.Ui/Controls/ComboBox/ComboBox.xaml
@@ -46,9 +46,9 @@
diff --git a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs
index bfad59954..292a8bf70 100644
--- a/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs
+++ b/src/Wpf.Ui/Controls/ContentDialog/ContentDialog.cs
@@ -629,6 +629,7 @@ protected virtual void OnLoaded()
private Size GetNewDialogSize(Size desiredSize)
{
+ // TODO: Handle negative values
var paddingWidth = Padding.Left + Padding.Right;
var paddingHeight = Padding.Top + Padding.Bottom;
diff --git a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml
index d627afdcb..c6c338051 100644
--- a/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml
+++ b/src/Wpf.Ui/Controls/ContextMenu/ContextMenu.xaml
@@ -5,9 +5,7 @@
All Rights Reserved.
-->
-
+