Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.0.5 #1165

Merged
merged 43 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a253702
Prevent icons in MenuItems from being tabstops
Difegue Apr 16, 2024
5f061c4
Merge pull request #1055 from Difegue/patch-1
pomianowski Apr 17, 2024
d733776
Fix incorrectly refactored High Contrast theme dictionary selection
Difegue Apr 19, 2024
dfcf3ad
Merge branch 'development' into patch-2
pomianowski Apr 19, 2024
d88b815
Merge pull request #1063 from Difegue/patch-2
pomianowski Apr 20, 2024
d33ecf3
Fixed the markup extension for the SymbolIcon and FontIcon class not …
m0lDaViA Apr 22, 2024
5525c2b
Rewrite of the arc class. Added SweepDirection as property, viewbox t…
m0lDaViA Apr 30, 2024
a35eb01
Fixed the PenLineCap property.
m0lDaViA May 1, 2024
4471cb9
Added back doc and removed regions.
m0lDaViA May 4, 2024
bdc2182
Merge pull request #1067 from m0lDaViA/development
pomianowski May 5, 2024
8ebf43e
Well, it can be null
pomianowski May 5, 2024
ef742b5
Format code
pomianowski May 5, 2024
a0aae10
Update themes.md
jonmotos May 9, 2024
5b92450
Merge branch 'development' into patch-1
pomianowski May 9, 2024
77b0c26
Update UiApplication.cs
ricaun May 9, 2024
2f51370
Update UiApplication.cs
pomianowski May 12, 2024
22c4dc1
Merge pull request #1080 from jonmotos/patch-1
pomianowski May 12, 2024
7a95878
Update UiApplication.cs
pomianowski May 12, 2024
493d1e0
Merge pull request #1082 from ricaun/patch-2
pomianowski May 12, 2024
303c7bb
[TYPO] link to 404 (#1102)
JulesDebeaumont Jun 2, 2024
334ded5
Fix warnings (#1104)
drolevar Jun 2, 2024
232b9c6
fix non-legacy backdrop when switching themes (#1094)
Muniwedesu Jun 2, 2024
259faf2
fix: possible null reference exceptions in PasswordBox (#1091)
textGamex Jun 2, 2024
00a4c0c
fix: TextBox, NumberBox, PasswordBox Placeholder Not Working Properl…
textGamex Jun 4, 2024
150e05d
fix: PlaceholderText may not display promptly under certain circumst…
textGamex Jun 8, 2024
ba8a241
Update themes.md (#1114)
jm6271 Jun 8, 2024
cc35ab2
Update window titlebar color (#1122)
pomianowski Jun 10, 2024
9c55f37
fix: possible multiple invocations of the INavigationAware interface …
textGamex Jun 10, 2024
7db4af2
Update `INotifyCollectionChanged` events in `MenuItems` and `FooterMe…
ioswald Jun 11, 2024
f340d47
Format code
pomianowski Jun 11, 2024
09eeabd
Update themes.md (#1124)
getup700 Jun 11, 2024
305ee57
Revert changes that make it impossible to use {ui:SymbolIcon} as the …
Difegue Jul 24, 2024
1979071
Fix DynamicScrollViewer not responding to touch events (#1154)
Difegue Jul 24, 2024
454c73b
fix:SnackbarPresenter might throw ObjectDisposedException. (#1138)
textGamex Jul 24, 2024
eabd654
Fix MessageBox Button Icons (#1164)
stepwise-alan Jul 24, 2024
24bc09d
chore: update RadioButton.xaml (#1135)
eltociear Jul 24, 2024
030f584
Workaround for touch input triggering alongside the hwnd hook on titl…
Difegue Jul 24, 2024
432cc70
fix: setting NotifyIcon.TooltipText at runtime doesn't work (#1132)
textGamex Jul 24, 2024
c2afe6c
Doc: supplement the document content. (#1119)
textGamex Jul 24, 2024
ecd36c1
Fix: MessageBox does not support WindowStartupLocation (#1130)
textGamex Jul 24, 2024
a407870
Replace Assembly.Location to AppContext.BaseDirectory (#1149)
sappho192 Jul 24, 2024
4aeb0bf
Fix: PasswordBox does not accept PasswordChar as input (#1141)
textGamex Jul 24, 2024
63f0f0c
Bump version
pomianowski Jul 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>3.0.4</Version>
<Version>3.0.5</Version>
<LangVersion>12.0</LangVersion>
<Deterministic>true</Deterministic>
</PropertyGroup>
Expand Down
154 changes: 154 additions & 0 deletions docs/documentation/navigation-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,157 @@ RootNavigation.Navigate(2);
```

## Pane display mode

## Set initial page

NavigationPage.xaml

```xml
<ui:NavigationView x:Name="RootNavigation"></ui:NavigationView>
```

NavigationPage.xaml.cs

```csharp
public partial class NavigationPage : Page
{
public NavigationPage(NavigationPageModel model)
{
InitializeComponent();

DataContext = model;
Loaded += (_, _) => RootNavigation.Navigate(type(MyDashboardClass));
}
}
```

## Using Navigation in the MVVM

Firstly, you need to implement the `IPageService` interface

```csharp
// from src/Wpf.Ui.Demo.Mvvm/Services/PageService.cs
public class PageService : IPageService
{
/// <summary>
/// Service which provides the instances of pages.
/// </summary>
private readonly IServiceProvider _serviceProvider;

/// <summary>
/// Initializes a new instance of the <see cref="PageService"/> class and attaches the <see cref="IServiceProvider"/>.
/// </summary>
public PageService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}

/// <inheritdoc />
public T? GetPage<T>()
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));
}

/// <inheritdoc />
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;
}
}
```

Then, inject it into the IoC container.

```csharp
var services = new ServiceCollection();

services.AddSingleton<MainWindow>();
services.AddSingleton<MainWindowViewModel>();
services.AddSingleton<IPageService, PageService>();

// inject View and ViewModel
services.AddSingleton<MainWindow>();
services.AddSingleton<MainWindowViewModel>();
services.AddSingleton<HomePage>();
services.AddSingleton<HomePageModel>();
services.AddSingleton<CounterPage>();
services.AddSingleton<CounterPageModel>();
```

Lastly, adjust the code for the navigation window.

```xml
<Window
x:Class="NavigationDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:NavigationDemo"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Title="Navigation Window"
Width="800"
Height="450"
d:DataContext="{d:DesignInstance local:MainWindowViewModel}"
mc:Ignorable="d">

<ui:NavigationView x:Name="RootNavigationView" MenuItemsSource="{Binding NavigationItems}"/>
</Window>
```

```csharp
using System.Collections.ObjectModel;
using System.Windows;
using CommunityToolkit.Mvvm.ComponentModel;
using Wpf.Ui;
using Wpf.Ui.Controls;

public partial class MainWindow : Window
{
public MainWindow(IPageService pageService, MainWindowViewModel model)
{
DataContext = model;
InitializeComponent();

// Set the page service for the navigation control.
RootNavigationView.SetPageService(pageService);
}
}

public partial class MainWindowViewModel : ObservableObject
{
[ObservableProperty]
private ObservableCollection<object> _navigationItems = [];

public MainWindowViewModel()
{
NavigationItems =
[
new NavigationViewItem()
{
Content = "Home",
Icon = new SymbolIcon { Symbol = SymbolRegular.Home24 },
TargetPageType = typeof(HomePage)
},
new NavigationViewItem()
{
Content = "Counter",
TargetPageType = typeof(CounterPage)
},
];
}
}
```

Alternatively, you can use the **WPF UI** Visual Studio Extension that includes a project template for MVVM pattern.
2 changes: 1 addition & 1 deletion docs/documentation/nuget.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ NuGet is a free, open-source package management system for the Microsoft .NET pl

# Done!

Package installed, to learn more, go to the [**Getting started**](/tutorial/getting-started.html) page.
Package installed, to learn more, go to the [**Getting started**](/documentation/getting-started.html) page.
22 changes: 11 additions & 11 deletions docs/documentation/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Or, you can add **WPF UI** resources manually.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Wpf.Ui;component/Styles/Theme/Dark.xaml" />
<ResourceDictionary Source="pack://application:,,,/Wpf.Ui;component/Styles/Wpf.Ui.xaml" />
<ResourceDictionary Source="pack://application:,,,/Wpf.Ui;component/Resources/Theme/Dark.xaml" />
<ResourceDictionary Source="pack://application:,,,/Wpf.Ui;component/Resources/Wpf.Ui.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Expand All @@ -37,16 +37,16 @@ Or, you can add **WPF UI** resources manually.
If you want to change the theme while the application is running, you can call the static `Apply` method of the `Theme` class.

```csharp
Wpf.Ui.Appearance.Theme.Apply(
Wpf.Ui.Appearance.ThemeType.Light, // Theme type
Wpf.Ui.Appearance.BackgroundType.Mica, // Background type
true // Whether to change accents automatically
Wpf.Ui.Appearance.ApplicationThemeManager.Apply(
Wpf.Ui.Appearance.ApplicationTheme.Light, // Theme type
Wpf.Ui.Controls.WindowBackdropType.Mica, // Background type
true // Whether to change accents automatically
);
```

### Automatic change

The theme can be changed automatically when the operating system changes its background or accent using the [Watcher](https://github.com/lepoco/wpfui/blob/main/src/Wpf.Ui/Appearance/Watcher.cs) class.
The theme can be changed automatically when the operating system changes its background or accent using the [SystemThemeWatcher](https://github.com/lepoco/wpfui/blob/main/src/Wpf.Ui/Appearance/SystemThemeWatcher.cs) class.

```csharp
namespace MyApp;
Expand All @@ -59,10 +59,10 @@ public partial class MainWindow : Window

Loaded += (sender, args) =>
{
Wpf.Ui.Appearance.Watcher.Watch(
this, // Window class
Wpf.Ui.Appearance.BackgroundType.Mica, // Background type
true // Whether to change accents automatically
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(
this, // Window class
Wpf.Ui.Controls.WindowBackdropType.Mica, // Background type
true // Whether to change accents automatically
);
};
}
Expand Down
5 changes: 5 additions & 0 deletions src/Wpf.Ui.Demo.Simple/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +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.

using System.Windows;

[assembly: ThemeInfo(
Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Extension.Template.Blank/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class App
// https://docs.microsoft.com/dotnet/core/extensions/logging
private static readonly IHost _host = Host
.CreateDefaultBuilder()
.ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)); })
.ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)); })
.ConfigureServices((context, services) =>
{
throw new NotImplementedException("No service or window was registered.");
Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Extension.Template.Compact/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public partial class App
// https://docs.microsoft.com/dotnet/core/extensions/logging
private static readonly IHost _host = Host
.CreateDefaultBuilder()
.ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)); })
.ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)); })
.ConfigureServices((context, services) =>
{
services.AddHostedService<ApplicationHostService>();
Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Extension.Template.Fluent/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public partial class App
// https://docs.microsoft.com/dotnet/core/extensions/logging
private static readonly IHost _host = Host
.CreateDefaultBuilder()
.ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)); })
.ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)); })
.ConfigureServices((context, services) =>
{
services.AddHostedService<ApplicationHostService>();
Expand Down
5 changes: 5 additions & 0 deletions src/Wpf.Ui.FontMapper/FontSource.cs
Original file line number Diff line number Diff line change
@@ -1,3 +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.FontMapper;

class FontSource
Expand Down
7 changes: 6 additions & 1 deletion src/Wpf.Ui.FontMapper/GitTag.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
namespace Wpf.Ui.FontMapper;
// 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.FontMapper;

record GitTag(string Ref, string Node_Id, string Url);
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using Wpf.Ui.Controls;
// 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.Gallery.ControlsLookup;
using Wpf.Ui.Gallery.ViewModels.Pages.Layout;

Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.SyntaxHighlight/Highlighter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// 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.
//

// TODO: This class is work in progress.

using System;
Expand Down
2 changes: 2 additions & 0 deletions src/Wpf.Ui.Tray/Controls/NotifyIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ private static void OnTooltipTextChanged(DependencyObject d, DependencyPropertyC
}

notifyIcon.TooltipText = e.NewValue as string ?? string.Empty;
notifyIcon.internalNotifyIconManager.TooltipText = notifyIcon.TooltipText;
_ = notifyIcon.internalNotifyIconManager.ModifyToolTip();
}

private static void OnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Tray/Hicon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// 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.
//

// TODO: This class is the only reason for using System.Drawing.Common.
// It is worth looking for a way to get hIcon without using it.

Expand Down
5 changes: 5 additions & 0 deletions src/Wpf.Ui.Tray/INotifyIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ internal interface INotifyIcon
/// </summary>
bool ModifyIcon();

/// <summary>
/// Tries to modify the tooltip of the <see cref="INotifyIcon"/> in the shell.
/// </summary>
bool ModifyToolTip();

/// <summary>
/// Tries to remove the <see cref="INotifyIcon"/> from the shell.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Wpf.Ui.Tray/Internal/InternalNotifyIconManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ public virtual bool ModifyIcon()
return TrayManager.ModifyIcon(this);
}

/// <inheritdoc />
public virtual bool ModifyToolTip()
{
return TrayManager.ModifyToolTip(this);
}

/// <inheritdoc />
public virtual bool Unregister()
{
Expand Down
13 changes: 13 additions & 0 deletions src/Wpf.Ui.Tray/TrayManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ public static bool ModifyIcon(INotifyIcon notifyIcon)
return Interop.Shell32.Shell_NotifyIcon(Interop.Shell32.NIM.MODIFY, notifyIcon.ShellIconData);
}

public static bool ModifyToolTip(INotifyIcon notifyIcon)
{
if (!notifyIcon.IsRegistered)
{
return true;
}

notifyIcon.ShellIconData.szTip = notifyIcon.TooltipText;
notifyIcon.ShellIconData.uFlags |= Interop.Shell32.NIF.TIP;

return Interop.Shell32.Shell_NotifyIcon(Interop.Shell32.NIM.MODIFY, notifyIcon.ShellIconData);
}

/// <summary>
/// Tries to remove the <see cref="INotifyIcon"/> from the shell.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui/Appearance/ApplicationThemeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static void Apply(
SystemTheme.HC1 => "HC1",
SystemTheme.HC2 => "HC2",
SystemTheme.HCBlack => "HCBlack",
SystemTheme.HCWhite => "HCBlack",
SystemTheme.HCWhite => "HCWhite",
_ => "HCWhite",
};
break;
Expand Down
Loading