diff --git a/.github/workflows/build_artifacts.yml b/.github/workflows/build_artifacts.yml
index 36ffa01414..389c02a410 100644
--- a/.github/workflows/build_artifacts.yml
+++ b/.github/workflows/build_artifacts.yml
@@ -32,8 +32,8 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
- 6.x
8.x
+ 9.x
- name: Restore dependencies
run: dotnet restore ${{ env.solution }}
@@ -54,7 +54,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Screenshots-${{ github.run_number }}
- path: ${{ github.workspace }}tests\MaterialDesignThemes.UITests\bin\${{ inputs.build-configuration }}\net8.0-windows7\Screenshots
+ path: ${{ github.workspace }}\tests\MaterialDesignThemes.UITests\bin\${{ inputs.build-configuration }}\net9.0-windows\Screenshots
if-no-files-found: ignore
- name: Build NuGets
diff --git a/Directory.packages.props b/Directory.packages.props
index b58226de08..37ca871f37 100644
--- a/Directory.packages.props
+++ b/Directory.packages.props
@@ -1,9 +1,9 @@
-
+
-
+
@@ -14,7 +14,7 @@
-
+
@@ -24,11 +24,10 @@
+
+
-
-
-
-
+
diff --git a/MaterialDesignToolkit.Full.sln b/MaterialDesignToolkit.Full.sln
index d27338256c..6414dbdcc2 100644
--- a/MaterialDesignToolkit.Full.sln
+++ b/MaterialDesignToolkit.Full.sln
@@ -33,9 +33,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.packages.props = Directory.packages.props
.config\dotnet-tools.json = .config\dotnet-tools.json
global.json = global.json
- MaterialDesignColors.nuspec = MaterialDesignColors.nuspec
- MaterialDesignThemes.MahApps.nuspec = MaterialDesignThemes.MahApps.nuspec
- MaterialDesignThemes.nuspec = MaterialDesignThemes.nuspec
build\MigrateBrushes.ps1 = build\MigrateBrushes.ps1
nuget.config = nuget.config
README.md = README.md
diff --git a/global.json b/global.json
index c19a2e057c..ccbe73ca13 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "8.0.100",
+ "version": "9.0.300",
"rollForward": "latestMinor"
}
}
diff --git a/src/MahMaterialDragablzMashUp/MahAppsDragablzDemo.csproj b/src/MahMaterialDragablzMashUp/MahAppsDragablzDemo.csproj
index 4a38274b38..e434e02469 100644
--- a/src/MahMaterialDragablzMashUp/MahAppsDragablzDemo.csproj
+++ b/src/MahMaterialDragablzMashUp/MahAppsDragablzDemo.csproj
@@ -2,7 +2,7 @@
WinExe
- net472;net6.0-windows;net8.0-windows
+ net472;net8.0-windows
true
..\
true
diff --git a/src/MainDemo.Wpf/App.xaml b/src/MainDemo.Wpf/App.xaml
index 78e99066d6..a5c2537ae3 100644
--- a/src/MainDemo.Wpf/App.xaml
+++ b/src/MainDemo.Wpf/App.xaml
@@ -22,7 +22,7 @@
If you would prefer to use your own colors, there is an option for that as well:
PrimaryColor and SecondaryColor also support the constant string "Inherit" to specify the color should use the system theme accent color
-->
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1966-JUL-30
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- True
-
-
+
+
-
-
- False
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/MainDemo.Wpf/Dialogs.xaml.cs b/src/MainDemo.Wpf/Dialogs.xaml.cs
index f8816bb7df..5347287fc0 100644
--- a/src/MainDemo.Wpf/Dialogs.xaml.cs
+++ b/src/MainDemo.Wpf/Dialogs.xaml.cs
@@ -1,4 +1,5 @@
using System.Diagnostics;
+using System.Threading.Tasks;
using MaterialDesignDemo.Domain;
using MaterialDesignThemes.Wpf;
@@ -11,6 +12,7 @@ public Dialogs()
DataContext = new DialogsViewModel();
InitializeComponent();
BlurRadiusSlider.Value = DialogHost.DefaultBlurRadius;
+ tbBlurRadius.Text = DialogOptions.Default.BlurRadius.ToString();
}
private void Sample1_DialogHost_OnDialogClosing(object sender, DialogClosingEventArgs eventArgs)
@@ -87,4 +89,26 @@ private void Sample6_ResetBlur(object sender, RoutedEventArgs e)
{
BlurRadiusSlider.Value = DialogHost.DefaultBlurRadius;
}
+
+ private async void Sample7_OpenWithDialogOptions(object sender, RoutedEventArgs e)
+ {
+ var options = new DialogOptions()
+ {
+ OpenedEventHandler = cbOpenedEventHandler.IsChecked == true ? (_, _) => MessageBox.Show("OpenedEventHandler raised") : null,
+ ClosingEventHandler = cbClosingEventHandler.IsChecked == true ? (_, _) => MessageBox.Show("ClosingEventHandler raised") : null,
+ ClosedEventHandler = cbClosedEventHandler.IsChecked == true ? (_, _) => MessageBox.Show("ClosedEventHandler raised") : null,
+ IsFullscreen = cbIsFullscreen.IsChecked!.Value,
+ ShowCloseButton = cbShowCloseButton.IsChecked!.Value,
+ CloseOnClickAway = cbCloseOnClickAway.IsChecked!.Value,
+ ApplyBlurEffect = cbApplyBlurEffect.IsChecked!.Value,
+ BlurRadius = double.TryParse(tbBlurRadius.Text, out double parsedRadius) ? parsedRadius : 0
+ };
+
+ var dialogContent = new TextBlock()
+ {
+ Text = "Some dialog content",
+ Margin = new Thickness(32)
+ };
+ await DialogHost.Show(dialogContent, "RootDialog", options);
+ }
}
diff --git a/src/MainDemo.Wpf/Domain/DocumentationLinks.xaml b/src/MainDemo.Wpf/Domain/DocumentationLinks.xaml
index 27ad1aecd6..d08590bb98 100644
--- a/src/MainDemo.Wpf/Domain/DocumentationLinks.xaml
+++ b/src/MainDemo.Wpf/Domain/DocumentationLinks.xaml
@@ -3,9 +3,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:domain="clr-namespace:MaterialDesignDemo.Domain"
+ xmlns:sharedDomain="clr-namespace:MaterialDesignDemo.Shared.Domain"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- d:DataContext="{d:DesignInstance domain:DemoItem,
+ d:DataContext="{d:DesignInstance sharedDomain:DemoItem,
IsDesignTimeCreatable=True}"
d:DesignHeight="300"
d:DesignWidth="300"
diff --git a/src/MainDemo.Wpf/Domain/MainWindowViewModel.cs b/src/MainDemo.Wpf/Domain/MainWindowViewModel.cs
index 12e4238fc8..feb1fef7cf 100644
--- a/src/MainDemo.Wpf/Domain/MainWindowViewModel.cs
+++ b/src/MainDemo.Wpf/Domain/MainWindowViewModel.cs
@@ -450,6 +450,14 @@ private static IEnumerable GenerateDemoItems(ISnackbarMessageQueue sna
DocumentationLink.ApiLink(),
DocumentationLink.ApiLink()
]);
+
+ yield return new DemoItem(
+ "ToolTips",
+ typeof(ToolTips),
+ [
+ DocumentationLink.DemoPageLink(),
+ DocumentationLink.DemoPageLink("Demo View Model", "Domain"),
+ ]);
}
private bool DemoItemsFilter(object obj)
diff --git a/src/MainDemo.Wpf/MainWindow.xaml b/src/MainDemo.Wpf/MainWindow.xaml
index d88dbb49c5..9e3f53fb09 100644
--- a/src/MainDemo.Wpf/MainWindow.xaml
+++ b/src/MainDemo.Wpf/MainWindow.xaml
@@ -7,6 +7,7 @@
xmlns:materialDesignConverters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="clr-namespace:System;assembly=mscorlib"
+ xmlns:sharedDomain="clr-namespace:MaterialDesignDemo.Shared.Domain"
Title="Material Design in XAML"
Width="1150"
d:DataContext="{d:DesignInstance domain:MainWindowViewModel}"
@@ -78,7 +79,7 @@
-
+
diff --git a/src/MainDemo.Wpf/MainWindow.xaml.cs b/src/MainDemo.Wpf/MainWindow.xaml.cs
index 41e24837b7..f88f2766c9 100644
--- a/src/MainDemo.Wpf/MainWindow.xaml.cs
+++ b/src/MainDemo.Wpf/MainWindow.xaml.cs
@@ -74,7 +74,6 @@ private async void MenuPopupButton_OnClick(object sender, RoutedEventArgs e)
{
Message = { Text = ((ButtonBase)sender).Content.ToString() }
};
-
await DialogHost.Show(sampleMessageDialog, "RootDialog");
}
@@ -115,5 +114,5 @@ private static void ModifyTheme(bool isDarkTheme)
private void OnSelectedItemChanged(object sender, DependencyPropertyChangedEventArgs e)
=> MainScrollViewer.ScrollToHome();
-
+
}
diff --git a/src/MainDemo.Wpf/MaterialDesignDemo.csproj b/src/MainDemo.Wpf/MaterialDesignDemo.csproj
index c461bb71dc..311ef14627 100644
--- a/src/MainDemo.Wpf/MaterialDesignDemo.csproj
+++ b/src/MainDemo.Wpf/MaterialDesignDemo.csproj
@@ -2,7 +2,7 @@
WinExe
- net472;net6.0-windows;net8.0-windows
+ net472;net8.0-windows
true
true
favicon.ico
diff --git a/src/MainDemo.Wpf/Properties/launchSettings.json b/src/MainDemo.Wpf/Properties/launchSettings.json
index 3b8cbc0041..d7f7960d01 100644
--- a/src/MainDemo.Wpf/Properties/launchSettings.json
+++ b/src/MainDemo.Wpf/Properties/launchSettings.json
@@ -2,7 +2,7 @@
"profiles": {
"Demo App": {
"commandName": "Project",
- "commandLineArgs": "-p Home -t Inherit -f LeftToRight"
+ "commandLineArgs": "-p Card -t Light -f LeftToRight"
}
}
}
diff --git a/src/MainDemo.Wpf/ToolTips.xaml b/src/MainDemo.Wpf/ToolTips.xaml
new file mode 100644
index 0000000000..df0cbf315b
--- /dev/null
+++ b/src/MainDemo.Wpf/ToolTips.xaml
@@ -0,0 +1,167 @@
+
+
+
+
+
+
+
+ 0,16,0,0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/MainDemo.Wpf/ToolTips.xaml.cs b/src/MainDemo.Wpf/ToolTips.xaml.cs
new file mode 100644
index 0000000000..a0cb14ca01
--- /dev/null
+++ b/src/MainDemo.Wpf/ToolTips.xaml.cs
@@ -0,0 +1,15 @@
+using MaterialDesignDemo.Shared.Domain;
+
+namespace MaterialDesignDemo;
+
+///
+/// Interaction logic for ToolTips.xaml
+///
+public partial class ToolTips : UserControl
+{
+ public ToolTips()
+ {
+ DataContext = new ToolTipsViewModel();
+ InitializeComponent();
+ }
+}
diff --git a/src/MaterialDesign3.Demo.Wpf/App.xaml b/src/MaterialDesign3.Demo.Wpf/App.xaml
index b1731454db..90ee3b9644 100644
--- a/src/MaterialDesign3.Demo.Wpf/App.xaml
+++ b/src/MaterialDesign3.Demo.Wpf/App.xaml
@@ -68,7 +68,7 @@
@@ -101,7 +101,7 @@
diff --git a/src/MaterialDesign3.Demo.Wpf/Buttons.xaml b/src/MaterialDesign3.Demo.Wpf/Buttons.xaml
index 2109cc52f7..265bb03e9b 100644
--- a/src/MaterialDesign3.Demo.Wpf/Buttons.xaml
+++ b/src/MaterialDesign3.Demo.Wpf/Buttons.xaml
@@ -2,13 +2,13 @@
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:domain="clr-namespace:MaterialDesign3Demo.Domain"
+ xmlns:sharedDomain="clr-namespace:MaterialDesignDemo.Shared.Domain;assembly=MaterialDesignDemo.Shared"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:materialDesignConverters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:smtx="clr-namespace:ShowMeTheXAML;assembly=ShowMeTheXAML"
xmlns:system="clr-namespace:System;assembly=mscorlib"
- d:DataContext="{d:DesignInstance domain:ButtonsViewModel}"
+ d:DataContext="{d:DesignInstance sharedDomain:ButtonsViewModel}"
d:DesignHeight="1200"
d:DesignWidth="800"
mc:Ignorable="d">
@@ -503,7 +503,7 @@
-
@@ -518,7 +518,7 @@
+ Fill="{DynamicResource MaterialDesign.Brush.TextBox.HoverBackground}" />
+ Fill="{DynamicResource MaterialDesign.Brush.TextBox.HoverBackground}" />
+ Fill="{DynamicResource MaterialDesign.Brush.TextBox.HoverBackground}" />
+ Fill="{DynamicResource MaterialDesign.Brush.TextBox.HoverBackground}" />
+ Foreground="{DynamicResource MaterialDesign.Brush.Primary.Dark.Foreground}">
@@ -222,8 +222,8 @@
UniqueKey="cards_4">
+ Background="{DynamicResource MaterialDesign.Brush.Primary.Light}"
+ Foreground="{DynamicResource MaterialDesign.Brush.Primary.Light.Foreground}">
@@ -231,8 +231,8 @@
@@ -244,8 +244,8 @@
UniqueKey="cards_6">
+ Background="{DynamicResource MaterialDesign.Brush.Primary.Dark}"
+ Foreground="{DynamicResource MaterialDesign.Brush.Primary.Dark.Foreground}">
+ IconBackground="{DynamicResource MaterialDesign.Brush.Primary.Dark}"
+ IconForeground="{DynamicResource MaterialDesign.Brush.Primary.Dark.Foreground}">
@@ -93,8 +93,8 @@
@@ -126,8 +126,8 @@
@@ -140,7 +140,7 @@
+ Fill="{DynamicResource MaterialDesign.Brush.TextBox.HoverBackground}" />
@@ -257,7 +257,7 @@
+ Fill="{DynamicResource MaterialDesign.Brush.TextBox.HoverBackground}" />
diff --git a/src/MaterialDesign3.Demo.Wpf/ColorTool.xaml b/src/MaterialDesign3.Demo.Wpf/ColorTool.xaml
index a2c3e807ec..2042d4a322 100644
--- a/src/MaterialDesign3.Demo.Wpf/ColorTool.xaml
+++ b/src/MaterialDesign3.Demo.Wpf/ColorTool.xaml
@@ -3,13 +3,13 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:MaterialDesignDemo.Shared.Converters;assembly=MaterialDesignDemo.Shared"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:domain="clr-namespace:MaterialDesign3Demo.Domain"
+ xmlns:sharedDomain="clr-namespace:MaterialDesignDemo.Shared.Domain;assembly=MaterialDesignDemo.Shared"
xmlns:local="clr-namespace:MaterialDesign3Demo"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:materialDesignColors="clr-namespace:MaterialDesignColors;assembly=MaterialDesignColors"
xmlns:materialDesignConverters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- d:DataContext="{d:DesignInstance Type=domain:ColorToolViewModel}"
+ d:DataContext="{d:DesignInstance Type=sharedDomain:ColorToolViewModel}"
d:DesignHeight="600"
d:DesignWidth="600"
mc:Ignorable="d">
@@ -128,7 +128,7 @@
@@ -202,10 +202,10 @@
Text="P">
@@ -217,16 +217,16 @@
-
-
+
-
-
+
@@ -257,15 +257,15 @@
-
-
+
-
@@ -276,7 +276,7 @@
@@ -288,10 +288,10 @@
Text="S">
@@ -303,17 +303,17 @@
-
-
+
-
-
+
@@ -342,14 +342,14 @@
-
-
+
-
@@ -360,7 +360,7 @@
@@ -372,10 +372,10 @@
Text="T">
@@ -407,14 +407,14 @@
-
-
+
-
@@ -425,7 +425,7 @@
@@ -437,10 +437,10 @@
Text="T">
diff --git a/src/MaterialDesign3.Demo.Wpf/ColorZones.xaml b/src/MaterialDesign3.Demo.Wpf/ColorZones.xaml
index da30c3c405..122fcf8d9d 100644
--- a/src/MaterialDesign3.Demo.Wpf/ColorZones.xaml
+++ b/src/MaterialDesign3.Demo.Wpf/ColorZones.xaml
@@ -83,8 +83,8 @@
diff --git a/src/MaterialDesign3.Demo.Wpf/ComboBoxes.xaml b/src/MaterialDesign3.Demo.Wpf/ComboBoxes.xaml
index d4f2b7fc1a..a5101a2923 100644
--- a/src/MaterialDesign3.Demo.Wpf/ComboBoxes.xaml
+++ b/src/MaterialDesign3.Demo.Wpf/ComboBoxes.xaml
@@ -1,13 +1,13 @@
@@ -121,7 +121,7 @@
+ Fill="{DynamicResource MaterialDesign.Brush.TextBox.HoverBackground}" />
@@ -213,7 +213,7 @@
+ Fill="{DynamicResource MaterialDesign.Brush.TextBox.HoverBackground}" />
diff --git a/src/MaterialDesign3.Demo.Wpf/Dialogs.xaml b/src/MaterialDesign3.Demo.Wpf/Dialogs.xaml
index a62692948b..29e1d24f03 100644
--- a/src/MaterialDesign3.Demo.Wpf/Dialogs.xaml
+++ b/src/MaterialDesign3.Demo.Wpf/Dialogs.xaml
@@ -94,7 +94,7 @@
@@ -226,11 +226,11 @@
DialogContent="{Binding Sample4Content}"
DialogTheme="Inherit"
IsOpen="{Binding IsSample4DialogOpen}"
- OverlayBackground="{DynamicResource PrimaryHueDarkBrush}">
+ OverlayBackground="{DynamicResource MaterialDesign.Brush.Primary.Dark}">
diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/DocumentationLinks.xaml b/src/MaterialDesign3.Demo.Wpf/Domain/DocumentationLinks.xaml
index 8cf98b3d54..31723cc476 100644
--- a/src/MaterialDesign3.Demo.Wpf/Domain/DocumentationLinks.xaml
+++ b/src/MaterialDesign3.Demo.Wpf/Domain/DocumentationLinks.xaml
@@ -78,6 +78,6 @@
-
+
\ No newline at end of file
diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/MainWindowViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/MainWindowViewModel.cs
index 23e49dcda2..1956cfec91 100644
--- a/src/MaterialDesign3.Demo.Wpf/Domain/MainWindowViewModel.cs
+++ b/src/MaterialDesign3.Demo.Wpf/Domain/MainWindowViewModel.cs
@@ -12,36 +12,31 @@ public class MainWindowViewModel : ViewModelBase
{
public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue, string? startupPage)
{
- DemoItems = new ObservableCollection
- {
+ DemoItems =
+ [
new DemoItem(
"Home",
typeof(Home),
- new[]
- {
+ [
new DocumentationLink(
DocumentationLinkType.Wiki,
$"{ConfigurationManager.AppSettings["GitHub"]}/wiki",
"WIKI"),
DocumentationLink.DemoPageLink()
- },
+ ],
selectedIcon: PackIconKind.Home,
- unselectedIcon: PackIconKind.HomeOutline)
- };
-
- foreach (var item in GenerateDemoItems(snackbarMessageQueue).OrderBy(i => i.Name))
- {
- DemoItems.Add(item);
- }
+ unselectedIcon: PackIconKind.HomeOutline),
+ .. GenerateDemoItems(snackbarMessageQueue).OrderBy(i => i.Name),
+ ];
- MainDemoItems = new ObservableCollection
- {
+ MainDemoItems =
+ [
DemoItems.First(x => x.Name == "Home"),
DemoItems.First(x => x.Name == "Buttons"),
DemoItems.First(x => x.Name == "Toggles"),
DemoItems.First(x => x.Name == "Fields"),
DemoItems.First(x => x.Name == "Pickers")
- };
+ ];
SelectedItem = DemoItems.FirstOrDefault(di => string.Equals(di.Name, startupPage, StringComparison.CurrentCultureIgnoreCase)) ?? DemoItems.First();
_demoItemsView = CollectionViewSource.GetDefaultView(DemoItems);
_demoItemsView.Filter = DemoItemsFilter;
@@ -136,148 +131,136 @@ private static IEnumerable GenerateDemoItems(ISnackbarMessageQueue sna
yield return new DemoItem(
"Palette",
typeof(PaletteSelector),
- new[]
- {
+ [
DocumentationLink.WikiLink("Brush-Names", "Brushes"),
DocumentationLink.WikiLink("Custom-Palette-Hues", "Custom Palettes"),
DocumentationLink.WikiLink("Swatches-and-Recommended-Colors", "Swatches"),
DocumentationLink.DemoPageLink("Demo View"),
DocumentationLink.DemoPageLink("Demo View Model"),
DocumentationLink.ApiLink()
- },
+ ],
selectedIcon: PackIconKind.Palette,
unselectedIcon: PackIconKind.PaletteOutline);
yield return new DemoItem(
"Color Tool",
typeof(ColorTool),
- new[]
- {
+ [
DocumentationLink.WikiLink("Brush-Names", "Brushes"),
DocumentationLink.WikiLink("Custom-Palette-Hues", "Custom Palettes"),
DocumentationLink.WikiLink("Swatches-and-Recommended-Colors", "Swatches"),
DocumentationLink.DemoPageLink("Demo View"),
DocumentationLink.DemoPageLink("Demo View Model"),
DocumentationLink.ApiLink()
- },
+ ],
selectedIcon: PackIconKind.Eyedropper,
unselectedIcon: PackIconKind.EyedropperVariant);
yield return new DemoItem(
"Buttons",
typeof(Buttons),
- new[]
- {
+ [
DocumentationLink.WikiLink("Button-Styles", "Buttons"),
DocumentationLink.DemoPageLink("Demo View"),
DocumentationLink.DemoPageLink("Demo View Model"),
DocumentationLink.StyleLink("Button"),
DocumentationLink.StyleLink("PopupBox"),
DocumentationLink.ApiLink()
- },
+ ],
selectedIcon: PackIconKind.GestureTapHold,
unselectedIcon: PackIconKind.GestureTapHold);
yield return new DemoItem(
"Toggles",
typeof(Toggles),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.StyleLink("ToggleButton", true),
DocumentationLink.StyleLink("CheckBox")
- },
+ ],
selectedIcon: PackIconKind.ToggleSwitch,
unselectedIcon: PackIconKind.ToggleSwitchOffOutline);
yield return new DemoItem(
"Rating Bar",
typeof(RatingBar),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.StyleLink("RatingBar"),
DocumentationLink.ApiLink()
- },
+ ],
selectedIcon: PackIconKind.Star,
unselectedIcon: PackIconKind.StarOutline);
yield return new DemoItem(
"Fields",
typeof(Fields),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.StyleLink("TextBox")
- },
+ ],
selectedIcon: PackIconKind.Pencil,
unselectedIcon: PackIconKind.PencilOutline);
yield return new DemoItem(
"Fields line up",
typeof(FieldsLineUp),
- new[]
- {
+ [
DocumentationLink.DemoPageLink()
- },
+ ],
selectedIcon: PackIconKind.PencilBox,
unselectedIcon: PackIconKind.PencilBoxOutline);
yield return new DemoItem(
"ComboBoxes",
typeof(ComboBoxes),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.StyleLink("ComboBox")
- },
+ ],
selectedIcon: PackIconKind.CheckboxMarked,
unselectedIcon: PackIconKind.CheckboxMarkedOutline);
yield return new DemoItem(
"Pickers",
typeof(Pickers),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.StyleLink("Clock"),
DocumentationLink.StyleLink("DatePicker"),
DocumentationLink.ApiLink()
- },
+ ],
selectedIcon: PackIconKind.Clock,
unselectedIcon: PackIconKind.ClockOutline);
yield return new DemoItem(
"Sliders",
typeof(Sliders),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.StyleLink("Slider")
- },
+ ],
selectedIcon: PackIconKind.TuneVariant,
unselectedIcon: PackIconKind.TuneVariant);
yield return new DemoItem(
"Chips",
typeof(Chips),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.StyleLink("Chip"),
DocumentationLink.ApiLink()
- },
+ ],
selectedIcon: PackIconKind.None,
unselectedIcon: PackIconKind.None);
yield return new DemoItem(
"Typography",
typeof(Typography),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.StyleLink("TextBlock", true)
- },
+ ],
selectedIcon: PackIconKind.FormatSize,
unselectedIcon: PackIconKind.FormatTitle)
{
@@ -287,24 +270,22 @@ private static IEnumerable GenerateDemoItems(ISnackbarMessageQueue sna
yield return new DemoItem(
"Cards",
typeof(Cards),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.StyleLink("Card"),
DocumentationLink.ApiLink()
- },
+ ],
selectedIcon: PackIconKind.Card,
unselectedIcon: PackIconKind.CardOutline);
yield return new DemoItem(
"Icon Pack",
typeof(IconPack),
- new[]
- {
+ [
DocumentationLink.DemoPageLink("Demo View"),
DocumentationLink.DemoPageLink("Demo View Model"),
DocumentationLink.ApiLink()
- },
+ ],
selectedIcon: PackIconKind.Robot,
unselectedIcon: PackIconKind.RobotOutline,
new IconPackViewModel(snackbarMessageQueue))
@@ -315,104 +296,95 @@ private static IEnumerable GenerateDemoItems(ISnackbarMessageQueue sna
yield return new DemoItem(
"Colour Zones",
typeof(ColorZones),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.ApiLink()
- },
+ ],
selectedIcon: PackIconKind.Subtitles,
unselectedIcon: PackIconKind.SubtitlesOutline);
yield return new DemoItem(
"Lists",
typeof(Lists),
- new[]
- {
+ [
DocumentationLink.DemoPageLink("Demo View"),
DocumentationLink.DemoPageLink("Demo View Model", "Domain"),
DocumentationLink.StyleLink("ListBox"),
DocumentationLink.StyleLink("ListView")
- },
+ ],
selectedIcon: PackIconKind.FormatListBulletedSquare,
unselectedIcon: PackIconKind.FormatListCheckbox);
yield return new DemoItem(
"Trees",
typeof(Trees),
- new[]
- {
+ [
DocumentationLink.DemoPageLink("Demo View"),
DocumentationLink.DemoPageLink("Demo View Model"),
DocumentationLink.StyleLink("TreeView")
- },
+ ],
selectedIcon: PackIconKind.FileTree,
unselectedIcon: PackIconKind.FileTreeOutline);
yield return new DemoItem(
"Data Grids",
typeof(DataGrids),
- new[]
- {
+ [
DocumentationLink.DemoPageLink("Demo View"),
DocumentationLink.DemoPageLink("Demo View Model", "Domain"),
DocumentationLink.StyleLink("DataGrid")
- },
+ ],
selectedIcon: PackIconKind.ViewGrid,
unselectedIcon: PackIconKind.ViewGridOutline);
yield return new DemoItem(
"Expander",
typeof(Expander),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.StyleLink("Expander")
- },
+ ],
selectedIcon: PackIconKind.UnfoldMoreHorizontal,
unselectedIcon: PackIconKind.UnfoldMoreHorizontal);
yield return new DemoItem(
"Group Boxes",
typeof(GroupBoxes),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.StyleLink("GroupBox")
- },
+ ],
selectedIcon: PackIconKind.TextBoxMultiple,
unselectedIcon: PackIconKind.TextBoxMultipleOutline);
yield return new DemoItem(
"Menus & Tool Bars",
typeof(MenusAndToolBars),
- new[]
- {
+ [
DocumentationLink.DemoPageLink(),
DocumentationLink.StyleLink("Menu"),
DocumentationLink.StyleLink("ToolBar")
- },
+ ],
selectedIcon: PackIconKind.DotsHorizontalCircle,
unselectedIcon: PackIconKind.DotsHorizontalCircleOutline);
yield return new DemoItem(
"Progress Indicators",
typeof(Progress),
- new[]
- {
+ [
DocumentationLink.DemoPageLink
diff --git a/src/MaterialDesign3.Demo.Wpf/RatingBar.xaml b/src/MaterialDesign3.Demo.Wpf/RatingBar.xaml
index 158772283e..010d4ae364 100644
--- a/src/MaterialDesign3.Demo.Wpf/RatingBar.xaml
+++ b/src/MaterialDesign3.Demo.Wpf/RatingBar.xaml
@@ -39,7 +39,7 @@
diff --git a/src/MaterialDesign3.Demo.Wpf/Snackbars.xaml b/src/MaterialDesign3.Demo.Wpf/Snackbars.xaml
index ab7150aaae..938e80c77f 100644
--- a/src/MaterialDesign3.Demo.Wpf/Snackbars.xaml
+++ b/src/MaterialDesign3.Demo.Wpf/Snackbars.xaml
@@ -47,7 +47,7 @@
+ Background="{DynamicResource MaterialDesign.Brush.Background}">
@@ -136,7 +136,7 @@
+ Background="{DynamicResource MaterialDesign.Brush.Background}">
@@ -186,7 +186,7 @@
+ Background="{DynamicResource MaterialDesign.Brush.Chip.Background}">
+ Background="{DynamicResource MaterialDesign.Brush.Background}">
diff --git a/src/MaterialDesign3.Demo.Wpf/Toggles.xaml b/src/MaterialDesign3.Demo.Wpf/Toggles.xaml
index a0deea4d91..2429ef3afd 100644
--- a/src/MaterialDesign3.Demo.Wpf/Toggles.xaml
+++ b/src/MaterialDesign3.Demo.Wpf/Toggles.xaml
@@ -382,7 +382,7 @@
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="0,24,0,0"
- BorderBrush="{DynamicResource MaterialDesignDivider}"
+ BorderBrush="{DynamicResource MaterialDesign.Brush.TextBox.HoverBackground}"
BorderThickness="0,1,0,0" />
@@ -498,19 +498,19 @@
+
+
+
+
+
+
+ 0,16,0,0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/MaterialDesign3.Demo.Wpf/ToolTips.xaml.cs b/src/MaterialDesign3.Demo.Wpf/ToolTips.xaml.cs
new file mode 100644
index 0000000000..92ce39a7d4
--- /dev/null
+++ b/src/MaterialDesign3.Demo.Wpf/ToolTips.xaml.cs
@@ -0,0 +1,13 @@
+namespace MaterialDesign3Demo;
+
+///
+/// Interaction logic for ToolTips.xaml
+///
+public partial class ToolTips : UserControl
+{
+ public ToolTips()
+ {
+ DataContext = new MaterialDesignDemo.Shared.Domain.ToolTipsViewModel();
+ InitializeComponent();
+ }
+}
diff --git a/src/MaterialDesign3.Demo.Wpf/TransitionsDemo/Slide5_TransitioningContent.xaml b/src/MaterialDesign3.Demo.Wpf/TransitionsDemo/Slide5_TransitioningContent.xaml
index b73785e17b..2c83f7a5a2 100644
--- a/src/MaterialDesign3.Demo.Wpf/TransitionsDemo/Slide5_TransitioningContent.xaml
+++ b/src/MaterialDesign3.Demo.Wpf/TransitionsDemo/Slide5_TransitioningContent.xaml
@@ -6,7 +6,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="300"
d:DesignWidth="300"
- Background="{DynamicResource MaterialDesignPaper}"
+ Background="{DynamicResource MaterialDesign.Brush.Background}"
mc:Ignorable="d">
diff --git a/src/MaterialDesignColors.Wpf/MaterialDesignColors.Wpf.csproj b/src/MaterialDesignColors.Wpf/MaterialDesignColors.Wpf.csproj
index f92936d0a5..ed1a0c31e9 100644
--- a/src/MaterialDesignColors.Wpf/MaterialDesignColors.Wpf.csproj
+++ b/src/MaterialDesignColors.Wpf/MaterialDesignColors.Wpf.csproj
@@ -2,7 +2,7 @@
MaterialDesignColors
MaterialDesignColors
- net462;net6.0-windows;net8.0-windows
+ net462;net8.0-windows
true
1.0.1
$([System.Text.RegularExpressions.Regex]::Replace("$(MDIXColorsVersion)", "-ci\d+$", ""))
diff --git a/src/MaterialDesignColors.Wpf/MaterialDesignColors.nuspec b/src/MaterialDesignColors.Wpf/MaterialDesignColors.nuspec
index a309b13841..008e852af7 100644
--- a/src/MaterialDesignColors.Wpf/MaterialDesignColors.nuspec
+++ b/src/MaterialDesignColors.Wpf/MaterialDesignColors.nuspec
@@ -26,9 +26,7 @@
-
-
\ No newline at end of file
+
diff --git a/src/MaterialDesignColors.Wpf/SwatchesProvider.cs b/src/MaterialDesignColors.Wpf/SwatchesProvider.cs
index 81385d83bb..3caefa06bc 100644
--- a/src/MaterialDesignColors.Wpf/SwatchesProvider.cs
+++ b/src/MaterialDesignColors.Wpf/SwatchesProvider.cs
@@ -12,6 +12,7 @@ namespace MaterialDesignColors;
///
public class SwatchesProvider
{
+ private static readonly object _syncLock = new();
///
/// Generates an instance reading swatches from the provided assembly, allowing
/// colours outside of the standard material palette to be loaded provided the are stored in the expected XAML format.
@@ -39,12 +40,7 @@ public SwatchesProvider(Assembly assembly)
Read(assemblyName, x.SingleOrDefault(y => y.match.Groups["type"].Value == "primary")?.key),
Read(assemblyName, x.SingleOrDefault(y => y.match.Groups["type"].Value == "secondary")?.key)
))
- .ToList() ??
-#if NETCOREAPP3_1_OR_GREATER
- (IEnumerable)Array.Empty();
-#else
- (IEnumerable)new Swatch[0];
-#endif
+ .ToList() ?? [];
}
///
@@ -98,8 +94,12 @@ static Hue GetHue(ResourceDictionary dictionary, DictionaryEntry entry)
if (assemblyName is null || path is null)
return null;
- return (ResourceDictionary)Application.LoadComponent(new Uri(
- $"/{assemblyName};component/{path.Replace(".baml", ".xaml")}",
- UriKind.RelativeOrAbsolute));
+ lock (_syncLock)
+ {
+ //NB: Application.LoadComponent is not thread safe
+ return (ResourceDictionary)Application.LoadComponent(new Uri(
+ $"/{assemblyName};component/{path.Replace(".baml", ".xaml")}",
+ UriKind.RelativeOrAbsolute));
+ }
}
}
diff --git a/src/MaterialDesignDemo.Shared/Domain/ToolTipsViewModel.cs b/src/MaterialDesignDemo.Shared/Domain/ToolTipsViewModel.cs
new file mode 100644
index 0000000000..d26b4fc180
--- /dev/null
+++ b/src/MaterialDesignDemo.Shared/Domain/ToolTipsViewModel.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using MaterialDesignThemes.Wpf;
+
+namespace MaterialDesignDemo.Shared.Domain;
+
+public partial class ToolTipsViewModel : ObservableObject
+{
+ public ToolTipsViewModel()
+ {
+ ResetToDefaults();
+ }
+
+ [RelayCommand]
+ private void ResetToDefaults()
+ {
+ IsPopupOpen = false;
+ SelectedElevation = Elevation.Dp6;
+ PopupUniformCornerRadius = 8;
+ PopupHorizontalOffset = 0;
+ PopupVerticalOffset = 0;
+ SelectedPopupBoxPlacementMode = PopupBoxPlacementMode.TopAndAlignCentres;
+ SelectedPopupAnimation = PopupAnimation.Fade;
+ SelectedPopupBoxPopupMode = PopupBoxPopupMode.Click;
+ }
+
+ [ObservableProperty]
+ private bool _isPopupOpen;
+
+ public List Elevations { get; } = EnumToEnumerable().ToList();
+ [ObservableProperty]
+ private Elevation _selectedElevation;
+
+ [ObservableProperty]
+ private int _popupUniformCornerRadius;
+
+ [ObservableProperty]
+ private int _popupHorizontalOffset;
+
+ [ObservableProperty]
+ private int _popupVerticalOffset;
+
+ public List PopupBoxPlacementModes { get; } = EnumToEnumerable().ToList();
+ [ObservableProperty]
+ private PopupBoxPlacementMode _selectedPopupBoxPlacementMode;
+
+ public List PopupAnimations { get; } = EnumToEnumerable().ToList();
+ [ObservableProperty]
+ private PopupAnimation _selectedPopupAnimation;
+
+ public List PopupBoxPopupModes { get; } = EnumToEnumerable().ToList();
+ [ObservableProperty]
+ private PopupBoxPopupMode _selectedPopupBoxPopupMode;
+
+ private static IEnumerable EnumToEnumerable() where T : Enum
+ => Enum.GetValues(typeof(T)).Cast();
+}
diff --git a/src/MaterialDesignDemo.Shared/MaterialDesignDemo.Shared.csproj b/src/MaterialDesignDemo.Shared/MaterialDesignDemo.Shared.csproj
index c1d486b0c3..65688d2960 100644
--- a/src/MaterialDesignDemo.Shared/MaterialDesignDemo.Shared.csproj
+++ b/src/MaterialDesignDemo.Shared/MaterialDesignDemo.Shared.csproj
@@ -1,7 +1,7 @@
- net472;net6.0-windows;net8.0-windows
+ net472;net8.0-windows
true
enable
diff --git a/src/MaterialDesignThemes.MahApps/MaterialDesignThemes.MahApps.csproj b/src/MaterialDesignThemes.MahApps/MaterialDesignThemes.MahApps.csproj
index 9f4fe5504f..5d0eb7f639 100644
--- a/src/MaterialDesignThemes.MahApps/MaterialDesignThemes.MahApps.csproj
+++ b/src/MaterialDesignThemes.MahApps/MaterialDesignThemes.MahApps.csproj
@@ -1,7 +1,7 @@
- net462;net6.0-windows;net8.0-windows
+ net462;net8.0-windows
true
1.0.1
$([System.Text.RegularExpressions.Regex]::Replace("$(MDIXMahAppsVersion)", "-ci\d+$", ""))
diff --git a/src/MaterialDesignThemes.MahApps/MaterialDesignThemes.MahApps.nuspec b/src/MaterialDesignThemes.MahApps/MaterialDesignThemes.MahApps.nuspec
index 064f3ec7a5..bdd981bb4a 100644
--- a/src/MaterialDesignThemes.MahApps/MaterialDesignThemes.MahApps.nuspec
+++ b/src/MaterialDesignThemes.MahApps/MaterialDesignThemes.MahApps.nuspec
@@ -22,11 +22,6 @@
-
-
-
-
-
@@ -38,9 +33,7 @@
-
-
\ No newline at end of file
+
diff --git a/src/MaterialDesignThemes.Wpf/AutoSuggestBox.cs b/src/MaterialDesignThemes.Wpf/AutoSuggestBox.cs
index 11214da0f9..71d028d35e 100644
--- a/src/MaterialDesignThemes.Wpf/AutoSuggestBox.cs
+++ b/src/MaterialDesignThemes.Wpf/AutoSuggestBox.cs
@@ -96,7 +96,11 @@ public object SelectedItem
set => SetValue(SelectedItemProperty, value);
}
public static readonly DependencyProperty SelectedItemProperty =
- DependencyProperty.Register(nameof(SelectedItem), typeof(object), typeof(AutoSuggestBox), new PropertyMetadata(default(object)));
+ DependencyProperty.Register(
+ nameof(SelectedItem),
+ typeof(object),
+ typeof(AutoSuggestBox),
+ new FrameworkPropertyMetadata(default(object), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public object SelectedValue
@@ -254,6 +258,7 @@ private bool CommitValueSelection(object? selectedValue)
{
CaretIndex = Text.Length;
}
+ SetCurrentValue(SelectedItemProperty, selectedValue);
CloseAutoSuggestionPopUp();
var args = new RoutedPropertyChangedEventArgs
/// Content to show (can be a control or view model).
- /// Allows access to opened event which would otherwise have been subscribed to on a instance.
+ /// Allows access to opened event which would otherwise have been subscribed to on a instance.
/// Task result is the parameter used to close the dialog, typically what is passed to the command.
- public static Task Show(object content, DialogOpenedEventHandler openedEventHandler)
+ [Obsolete(OBSOLETE_SHOW_API_MESSAGE, OLD_API_THROWS_ERROR)]
+ public static Task Show(object content, DialogOpenedEventHandler? openedEventHandler)
=> Show(content, null, openedEventHandler, null);
///
@@ -96,7 +142,8 @@ static DialogHost()
/// Content to show (can be a control or view model).
/// Allows access to closing event which would otherwise have been subscribed to on a instance.
/// Task result is the parameter used to close the dialog, typically what is passed to the command.
- public static Task Show(object content, DialogClosingEventHandler closingEventHandler)
+ [Obsolete(OBSOLETE_SHOW_API_MESSAGE, OLD_API_THROWS_ERROR)]
+ public static Task Show(object content, DialogClosingEventHandler? closingEventHandler)
=> Show(content, null, null, closingEventHandler);
///
@@ -106,6 +153,7 @@ static DialogHost()
/// Allows access to opened event which would otherwise have been subscribed to on a instance.
/// Allows access to closing event which would otherwise have been subscribed to on a instance.
/// Task result is the parameter used to close the dialog, typically what is passed to the command.
+ [Obsolete(OBSOLETE_SHOW_API_MESSAGE, OLD_API_THROWS_ERROR)]
public static Task Show(object content, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler)
=> Show(content, null, openedEventHandler, closingEventHandler);
@@ -117,6 +165,7 @@ static DialogHost()
/// Allows access to closing event which would otherwise have been subscribed to on a instance.
/// Allows access to closed event which would otherwise have been subscribed to on a instance.
/// Task result is the parameter used to close the dialog, typically what is passed to the command.
+ [Obsolete(OBSOLETE_SHOW_API_MESSAGE, OLD_API_THROWS_ERROR)]
public static Task Show(object content, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler, DialogClosedEventHandler? closedEventHandler)
=> Show(content, null, openedEventHandler, closingEventHandler, closedEventHandler);
@@ -126,6 +175,7 @@ static DialogHost()
/// Content to show (can be a control or view model).
/// of the instance where the dialog should be shown. Typically this will match an identifier set in XAML. null is allowed.
/// Task result is the parameter used to close the dialog, typically what is passed to the command.
+ [Obsolete(OBSOLETE_SHOW_API_MESSAGE, OLD_API_THROWS_ERROR)]
public static Task Show(object content, object dialogIdentifier)
=> Show(content, dialogIdentifier, null, null);
@@ -136,7 +186,8 @@ static DialogHost()
/// of the instance where the dialog should be shown. Typically this will match an identifier set in XAML. null is allowed.
/// Allows access to opened event which would otherwise have been subscribed to on a instance.
/// Task result is the parameter used to close the dialog, typically what is passed to the command.
- public static Task Show(object content, object dialogIdentifier, DialogOpenedEventHandler openedEventHandler)
+ [Obsolete(OBSOLETE_SHOW_API_MESSAGE, OLD_API_THROWS_ERROR)]
+ public static Task Show(object content, object dialogIdentifier, DialogOpenedEventHandler? openedEventHandler)
=> Show(content, dialogIdentifier, openedEventHandler, null);
///
@@ -146,7 +197,8 @@ static DialogHost()
/// of the instance where the dialog should be shown. Typically this will match an identifier set in XAML. null is allowed.
/// Allows access to closing event which would otherwise have been subscribed to on a instance.
/// Task result is the parameter used to close the dialog, typically what is passed to the command.
- public static Task Show(object content, object dialogIdentifier, DialogClosingEventHandler closingEventHandler)
+ [Obsolete(OBSOLETE_SHOW_API_MESSAGE, OLD_API_THROWS_ERROR)]
+ public static Task Show(object content, object dialogIdentifier, DialogClosingEventHandler? closingEventHandler)
=> Show(content, dialogIdentifier, null, closingEventHandler);
///
@@ -157,6 +209,7 @@ static DialogHost()
/// Allows access to opened event which would otherwise have been subscribed to on a instance.
/// Allows access to closing event which would otherwise have been subscribed to on a instance.
/// Task result is the parameter used to close the dialog, typically what is passed to the command.
+ [Obsolete(OBSOLETE_SHOW_API_MESSAGE, OLD_API_THROWS_ERROR)]
public static Task Show(object content, object? dialogIdentifier, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler)
=> Show(content, dialogIdentifier, openedEventHandler, closingEventHandler, null);
@@ -169,9 +222,14 @@ static DialogHost()
/// Allows access to closing event which would otherwise have been subscribed to on a instance.
/// Allows access to closed event which would otherwise have been subscribed to on a instance.
/// Task result is the parameter used to close the dialog, typically what is passed to the command.
+ [Obsolete(OBSOLETE_SHOW_API_MESSAGE, OLD_API_THROWS_ERROR)]
public static async Task Show(object content, object? dialogIdentifier, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler, DialogClosedEventHandler? closedEventHandler)
{
+#if NET7_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(content);
+#else
if (content is null) throw new ArgumentNullException(nameof(content));
+#endif
return await GetInstance(dialogIdentifier).ShowInternal(content, openedEventHandler, closingEventHandler, closedEventHandler);
}
@@ -221,7 +279,7 @@ private static DialogHost GetInstance(object? dialogIdentifier)
if (LoadedInstances.Count == 0)
throw new InvalidOperationException("No loaded DialogHost instances.");
- List targets = new();
+ List targets = [];
foreach (var instance in LoadedInstances.ToList())
{
if (instance.TryGetTarget(out DialogHost? dialogInstance))
@@ -255,6 +313,7 @@ private static DialogHost GetInstance(object? dialogIdentifier)
return targets[0];
}
+ [Obsolete(OBSOLETE_SHOW_API_MESSAGE, OLD_API_THROWS_ERROR)]
internal async Task ShowInternal(object content, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler, DialogClosedEventHandler? closedEventHandler)
{
if (IsOpen)
@@ -264,7 +323,7 @@ private static DialogHost GetInstance(object? dialogIdentifier)
AssertTargetableContent();
- if (content != null)
+ if (content is not null)
DialogContent = content;
_asyncShowOpenedEventHandler = openedEventHandler;
@@ -281,6 +340,161 @@ private static DialogHost GetInstance(object? dialogIdentifier)
return result;
}
+ public Task Show(object? content, DialogOptions? options = null)
+ => Show(content, null, options);
+
+ public static async Task Show(object? content, object? dialogIdentifier, DialogOptions? options = null)
+ {
+#if NET7_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(content);
+#else
+ if (content is null) throw new ArgumentNullException(nameof(content));
+#endif
+ return await GetInstance(dialogIdentifier).ShowInternal(content, options);
+ }
+
+ private void ApplyDialogOptions(DialogOptions options)
+ {
+ // Show/Hide CloseButton
+ if (_closeButton is not null)
+ {
+ options.PreviousCloseButtonVisibility = _closeButton.Visibility;
+ _closeButton.Visibility = options.ShowCloseButton ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ // Handle CloseOnClickAway
+ if (options.CloseOnClickAway)
+ {
+ if (_contentCoverGrid is not null)
+ _contentCoverGrid.MouseLeftButtonUp += OnCloseOnClickAway;
+ }
+ else
+ {
+ if (_contentCoverGrid is not null)
+ _contentCoverGrid.MouseLeftButtonUp -= OnCloseOnClickAway;
+ }
+
+ // Handle IsFullScreen (remove the dialogs margin and corner radius)
+ if (options.IsFullscreen)
+ {
+ options.PreviousDialogMargin = DialogMargin;
+ DialogMargin = new Thickness(0);
+
+ options.PreviousDialogContentUniformCornerRadius = DialogContentUniformCornerRadius;
+ DialogContentUniformCornerRadius = 0;
+
+ if (Window.GetWindow(this) is Window window)
+ {
+ window.LocationChanged += Window_SizeOrLocationChanged;
+ window.SizeChanged += Window_SizeOrLocationChanged;
+ }
+
+ if (_popup is Popup popup)
+ {
+ options.PreviousPopupHeight = popup.Height;
+ options.PreviousPopupWidth = popup.Width;
+ }
+
+ SetPopupSize(ActualHeight, ActualWidth);
+ }
+
+ if (options.ApplyBlurEffect && _contentPresenter is not null)
+ {
+ options.PreviousApplyBlurEffect = ApplyBlurBackground;
+ options.PreviousBlurRadius = BlurRadius;
+
+ _contentPresenter.Effect = new BlurEffect()
+ {
+ Radius = options.BlurRadius
+ };
+ }
+ }
+
+ private void RevertDialogOptions(DialogOptions options)
+ {
+ if (_closeButton is not null)
+ {
+ _closeButton.Visibility = options.PreviousCloseButtonVisibility;
+ }
+
+ if (options.CloseOnClickAway)
+ {
+ if (_contentCoverGrid is not null)
+ _contentCoverGrid.MouseLeftButtonUp -= OnCloseOnClickAway;
+ }
+
+ if (options.IsFullscreen)
+ {
+ DialogMargin = options.PreviousDialogMargin;
+ DialogContentUniformCornerRadius = options.PreviousDialogContentUniformCornerRadius;
+
+ if (Window.GetWindow(this) is Window window)
+ {
+ window.LocationChanged -= Window_SizeOrLocationChanged;
+ window.SizeChanged -= Window_SizeOrLocationChanged;
+ }
+
+ SetPopupSize(options.PreviousPopupHeight, options.PreviousPopupWidth);
+ }
+
+ if (options.ApplyBlurEffect && _contentPresenter is not null)
+ {
+ _contentPresenter.Effect = null;
+ ApplyBlurBackground = options.PreviousApplyBlurEffect;
+ BlurRadius = options.PreviousBlurRadius;
+ }
+ }
+
+ internal async Task ShowInternal(object content, DialogOptions? options = null)
+ {
+ if (IsOpen)
+ throw new InvalidOperationException("DialogHost is already open.");
+
+ options ??= DialogOptions.Default;
+
+ _dialogTaskCompletionSource = new TaskCompletionSource();
+
+ AssertTargetableContent();
+
+ ApplyDialogOptions(options);
+
+ if (content is not null)
+ DialogContent = content;
+
+ _asyncShowOpenedEventHandler = options.OpenedEventHandler;
+ _asyncShowClosingEventHandler = options.ClosingEventHandler;
+ _asyncShowClosedEventHandler = options.ClosedEventHandler;
+ SetCurrentValue(IsOpenProperty, true);
+
+ object? result = await _dialogTaskCompletionSource.Task;
+
+ _asyncShowOpenedEventHandler = null;
+ _asyncShowClosingEventHandler = null;
+ _asyncShowClosedEventHandler = null;
+
+ RevertDialogOptions(options);
+
+ return result;
+ }
+
+ private void OnCloseOnClickAway(object sender, MouseButtonEventArgs e)
+ {
+ // TODO implement CloseOnClickAwayParameter in DialogOptions class
+ if (CurrentSession is not null)
+ InternalClose(CloseOnClickAwayParameter);
+ }
+ private void Window_SizeOrLocationChanged(object sender, EventArgs e) => SetPopupSize(ActualHeight, ActualWidth);
+
+ private void SetPopupSize(double height, double width)
+ {
+ // TODO handle overwritten "PART_Popup"s which are not of type "PopupEx"
+ if (_popup is PopupEx popupEx)
+ {
+ _popup.Height = height;
+ _popup.Width = width;
+ popupEx.RefreshPosition();
+ }
+ }
#endregion
public DialogHost()
@@ -311,7 +525,7 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
{
var dialogHost = (DialogHost)dependencyObject;
- if (dialogHost._popupContentControl != null)
+ if (dialogHost._popupContentControl is not null)
ValidationAssist.SetSuppress(dialogHost._popupContentControl, !dialogHost.IsOpen);
VisualStateManager.GoToState(dialogHost, dialogHost.GetStateName(), !TransitionAssist.GetDisableTransitions(dialogHost));
@@ -322,7 +536,7 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
else
{
dialogHost._attachedDialogClosingEventHandler = null;
- if (dialogHost._currentSnackbarMessageQueueUnPauseAction != null)
+ if (dialogHost._currentSnackbarMessageQueueUnPauseAction is not null)
{
dialogHost._currentSnackbarMessageQueueUnPauseAction();
dialogHost._currentSnackbarMessageQueueUnPauseAction = null;
@@ -372,7 +586,7 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
var window = Window.GetWindow(dialogHost);
if (!dialogHost.IsRestoreFocusDisabled)
{
- dialogHost._restoreFocusDialogClose = window != null ? FocusManager.GetFocusedElement(window) : null;
+ dialogHost._restoreFocusDialogClose = window is not null ? FocusManager.GetFocusedElement(window) : null;
// Check restore focus override
if (dialogHost._restoreFocusDialogClose is DependencyObject dependencyObj &&
@@ -398,7 +612,7 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
CommandManager.InvalidateRequerySuggested();
UIElement? child = dialogHost.FocusPopup();
- if (child != null)
+ if (child is not null)
{
//https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/issues/187
//totally not happy about this, but on immediate validation we can get some weird looking stuff...give WPF a kick to refresh...
@@ -482,7 +696,7 @@ public string? DialogContentStringFormat
}
public static readonly DependencyProperty DialogMarginProperty = DependencyProperty.Register(
- "DialogMargin", typeof(Thickness), typeof(DialogHost), new PropertyMetadata(default(Thickness)));
+ nameof(DialogMargin), typeof(Thickness), typeof(DialogHost), new PropertyMetadata(default(Thickness)));
public Thickness DialogMargin
{
@@ -504,7 +718,7 @@ public DialogHostOpenDialogCommandDataContextSource OpenDialogCommandDataContext
}
public static readonly DependencyProperty CloseOnClickAwayProperty = DependencyProperty.Register(
- "CloseOnClickAway", typeof(bool), typeof(DialogHost), new PropertyMetadata(default(bool)));
+ nameof(CloseOnClickAway), typeof(bool), typeof(DialogHost), new PropertyMetadata(default(bool)));
///
/// Indicates whether the dialog will close if the user clicks off the dialog, on the obscured background.
@@ -516,7 +730,7 @@ public bool CloseOnClickAway
}
public static readonly DependencyProperty CloseOnClickAwayParameterProperty = DependencyProperty.Register(
- "CloseOnClickAwayParameter", typeof(object), typeof(DialogHost), new PropertyMetadata(default(object)));
+ nameof(CloseOnClickAwayParameter), typeof(object), typeof(DialogHost), new PropertyMetadata(default(object)));
///
/// Parameter to provide to close handlers if an close due to click away is instigated.
@@ -528,12 +742,12 @@ public object? CloseOnClickAwayParameter
}
public static readonly DependencyProperty SnackbarMessageQueueProperty = DependencyProperty.Register(
- "SnackbarMessageQueue", typeof(SnackbarMessageQueue), typeof(DialogHost), new PropertyMetadata(default(SnackbarMessageQueue), SnackbarMessageQueuePropertyChangedCallback));
+ nameof(SnackbarMessageQueue), typeof(SnackbarMessageQueue), typeof(DialogHost), new PropertyMetadata(default(SnackbarMessageQueue), SnackbarMessageQueuePropertyChangedCallback));
private static void SnackbarMessageQueuePropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
var dialogHost = (DialogHost)dependencyObject;
- if (dialogHost._currentSnackbarMessageQueueUnPauseAction != null)
+ if (dialogHost._currentSnackbarMessageQueueUnPauseAction is not null)
{
dialogHost._currentSnackbarMessageQueueUnPauseAction();
dialogHost._currentSnackbarMessageQueueUnPauseAction = null;
@@ -618,21 +832,31 @@ public double BlurRadius
public override void OnApplyTemplate()
{
- if (_contentCoverGrid != null)
+ if (_contentCoverGrid is not null)
_contentCoverGrid.MouseLeftButtonUp -= ContentCoverGridOnMouseLeftButtonUp;
+ if (_closeButton is not null)
+ _closeButton.Click -= CloseButtonOnClick;
+
_popup = GetTemplateChild(PopupPartName) as Popup;
_popupContentControl = GetTemplateChild(PopupContentPartName) as ContentControl;
_contentCoverGrid = GetTemplateChild(ContentCoverGridName) as Grid;
+ _closeButton = GetTemplateChild(CloseButtonPartName) as Button;
+ _contentPresenter = GetTemplateChild(ContentPresenterName) as ContentPresenter;
- if (_contentCoverGrid != null)
+ if (_contentCoverGrid is not null)
_contentCoverGrid.MouseLeftButtonUp += ContentCoverGridOnMouseLeftButtonUp;
+ if (_closeButton is not null)
+ _closeButton.Click += CloseButtonOnClick;
+
VisualStateManager.GoToState(this, GetStateName(), false);
base.OnApplyTemplate();
}
+ private void CloseButtonOnClick(object sender, RoutedEventArgs e) => CurrentSession?.Close();
+
#region restore focus properties
public static readonly DependencyProperty RestoreFocusElementProperty = DependencyProperty.RegisterAttached(
@@ -659,7 +883,7 @@ public bool IsRestoreFocusDisabled
public static readonly RoutedEvent DialogOpenedEvent =
EventManager.RegisterRoutedEvent(
- "DialogOpened",
+ nameof(DialogOpened),
RoutingStrategy.Bubble,
typeof(DialogOpenedEventHandler),
typeof(DialogHost));
@@ -706,7 +930,7 @@ protected void OnDialogOpened(DialogOpenedEventArgs eventArgs)
public static readonly RoutedEvent DialogClosingEvent =
EventManager.RegisterRoutedEvent(
- "DialogClosing",
+ nameof(DialogClosing),
RoutingStrategy.Bubble,
typeof(DialogClosingEventHandler),
typeof(DialogHost));
@@ -749,7 +973,7 @@ protected void OnDialogClosing(DialogClosingEventArgs eventArgs)
public static readonly RoutedEvent DialogClosedEvent =
EventManager.RegisterRoutedEvent(
- "DialogClosed",
+ nameof(DialogClosed),
RoutingStrategy.Bubble,
typeof(DialogClosedEventHandler),
typeof(DialogHost));
@@ -795,7 +1019,7 @@ protected void OnDialogClosed(DialogClosedEventArgs eventArgs)
internal void AssertTargetableContent()
{
var existingBinding = BindingOperations.GetBindingExpression(this, DialogContentProperty);
- if (existingBinding != null)
+ if (existingBinding is not null)
throw new InvalidOperationException(
"Content cannot be passed to a dialog via the OpenDialog if DialogContent already has a binding.");
}
@@ -886,7 +1110,7 @@ protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
private void ContentCoverGridOnMouseLeftButtonUp(object sender, MouseButtonEventArgs mouseButtonEventArgs)
{
- if (CloseOnClickAway && CurrentSession != null)
+ if (CloseOnClickAway && CurrentSession is not null)
InternalClose(CloseOnClickAwayParameter);
}
@@ -901,11 +1125,11 @@ private void OpenDialogHandler(object sender, ExecutedRoutedEventArgs executedRo
_attachedDialogClosedEventHandler = GetDialogClosedAttached(dependencyObject);
}
- if (executedRoutedEventArgs.Parameter != null)
+ if (executedRoutedEventArgs.Parameter is not null)
{
AssertTargetableContent();
- if (_popupContentControl != null)
+ if (_popupContentControl is not null)
{
_popupContentControl.DataContext = OpenDialogCommandDataContextSource switch
{
diff --git a/src/MaterialDesignThemes.Wpf/Internal/TreeListViewItemsCollection.cs b/src/MaterialDesignThemes.Wpf/Internal/TreeListViewItemsCollection.cs
index 324e1c1b69..0405bf0498 100644
--- a/src/MaterialDesignThemes.Wpf/Internal/TreeListViewItemsCollection.cs
+++ b/src/MaterialDesignThemes.Wpf/Internal/TreeListViewItemsCollection.cs
@@ -6,8 +6,8 @@ namespace MaterialDesignThemes.Wpf.Internal;
public class TreeListViewItemsCollection : ObservableCollection
{
- private List ItemLevels { get; } = new();
- private List ItemIsExpanded { get; } = new();
+ private List ItemLevels { get; } = [];
+ private List ItemIsExpanded { get; } = [];
public TreeListViewItemsCollection(object? wrappedSource)
{
diff --git a/src/MaterialDesignThemes.Wpf/ListBoxItemAssist.cs b/src/MaterialDesignThemes.Wpf/ListBoxItemAssist.cs
index d0675f472b..92350fd15b 100644
--- a/src/MaterialDesignThemes.Wpf/ListBoxItemAssist.cs
+++ b/src/MaterialDesignThemes.Wpf/ListBoxItemAssist.cs
@@ -61,4 +61,15 @@ public static void SetShowSelection(DependencyObject element, bool value)
public static readonly DependencyProperty ShowSelectionProperty =
DependencyProperty.RegisterAttached("ShowSelection", typeof(bool), typeof(ListBoxItemAssist), new PropertyMetadata(true));
#endregion
+
+ #region Cursor
+ public static Cursor GetCursor(DependencyObject obj)
+ => (Cursor)obj.GetValue(CursorProperty);
+
+ public static void SetCursor(DependencyObject obj, Cursor value)
+ => obj.SetValue(CursorProperty, value);
+
+ public static readonly DependencyProperty CursorProperty =
+ DependencyProperty.RegisterAttached("Cursor", typeof(Cursor), typeof(ListBoxItemAssist), new PropertyMetadata(Cursors.Hand));
+ #endregion
}
diff --git a/src/MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj b/src/MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj
index 262be69548..592420a96b 100644
--- a/src/MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj
+++ b/src/MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj
@@ -1,7 +1,7 @@
- net462;net6.0-windows;net8.0-windows
+ net462;net8.0-windows
true
1.0.1
$([System.Text.RegularExpressions.Regex]::Replace("$(MDIXVersion)", "-ci\d+$", ""))
diff --git a/src/MaterialDesignThemes.Wpf/MaterialDesignThemes.nuspec b/src/MaterialDesignThemes.Wpf/MaterialDesignThemes.nuspec
index 3472b6c5dd..6dac8e637c 100644
--- a/src/MaterialDesignThemes.Wpf/MaterialDesignThemes.nuspec
+++ b/src/MaterialDesignThemes.Wpf/MaterialDesignThemes.nuspec
@@ -21,10 +21,6 @@
-
-
-
-
@@ -35,14 +31,10 @@
-
-
-
\ No newline at end of file
+
diff --git a/src/MaterialDesignThemes.Wpf/PopupBox.cs b/src/MaterialDesignThemes.Wpf/PopupBox.cs
index d9fe9009fc..62df1e2fb9 100644
--- a/src/MaterialDesignThemes.Wpf/PopupBox.cs
+++ b/src/MaterialDesignThemes.Wpf/PopupBox.cs
@@ -384,8 +384,23 @@ public double PopupUniformCornerRadius
///
public Elevation PopupElevation
{
- get { return (Elevation) GetValue(PopupElevationProperty); }
- set { SetValue(PopupElevationProperty, value); }
+ get => (Elevation)GetValue(PopupElevationProperty);
+ set => SetValue(PopupElevationProperty, value);
+ }
+
+ ///
+ /// Gets or sets the animation of the popup card.
+ ///
+ public static readonly DependencyProperty PopupAnimationProperty = DependencyProperty.Register(
+ nameof(PopupAnimation), typeof(PopupAnimation), typeof(PopupBox), new PropertyMetadata(PopupAnimation.Fade));
+
+ ///
+ /// Gets or sets the animation of the popup card.
+ ///
+ public PopupAnimation PopupAnimation
+ {
+ get => (PopupAnimation)GetValue(PopupAnimationProperty);
+ set => SetValue(PopupAnimationProperty, value);
}
///
diff --git a/src/MaterialDesignThemes.Wpf/RatingBar.cs b/src/MaterialDesignThemes.Wpf/RatingBar.cs
index 2f1b43c3ac..fd45af708b 100644
--- a/src/MaterialDesignThemes.Wpf/RatingBar.cs
+++ b/src/MaterialDesignThemes.Wpf/RatingBar.cs
@@ -378,7 +378,7 @@ internal class TextBlockForegroundConverter : IMultiValueConverter
public static TextBlockForegroundConverter Instance { get; } = new();
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ public object? Convert(object?[]? values, Type targetType, object? parameter, CultureInfo culture)
{
if (values?.Length == 5
&& values[0] is SolidColorBrush brush
@@ -411,28 +411,28 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
return new SolidColorBrush(semiTransparent);
}
- GradientStopCollection CreateGradientStopCollection(Color originalColor, Color semiTransparent, double offset, bool invertDirection)
+ static GradientStopCollection CreateGradientStopCollection(Color originalColor, Color semiTransparent, double offset, bool invertDirection)
{
if (invertDirection)
{
- return new()
- {
- new GradientStop {Color = semiTransparent, Offset = offset},
- new GradientStop {Color = originalColor, Offset = offset},
- };
- }
- return new()
- {
+ return
+ [
+ new GradientStop {Color = semiTransparent, Offset = offset},
new GradientStop {Color = originalColor, Offset = offset},
- new GradientStop {Color = semiTransparent, Offset = offset}
- };
+ ];
+ }
+ return
+ [
+ new GradientStop {Color = originalColor, Offset = offset},
+ new GradientStop {Color = semiTransparent, Offset = offset}
+ ];
}
// This should never happen (returning actual brush to avoid the compilers squiggly line warning)
return Brushes.Transparent;
}
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
+ public object?[]? ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) => throw new NotImplementedException();
}
internal class PreviewIndicatorTransformXConverter : IMultiValueConverter
@@ -441,9 +441,9 @@ internal class PreviewIndicatorTransformXConverter : IMultiValueConverter
internal static double Margin => 2.0;
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ public object? Convert(object?[]? values, Type targetType, object? parameter, CultureInfo culture)
{
- if (values.Length >= 7
+ if (values?.Length >= 7
&& values[0] is double ratingBarButtonActualWidth
&& values[1] is double previewValueActualWidth
&& values[2] is Orientation ratingBarOrientation
@@ -482,7 +482,7 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
return 1.0;
}
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
+ public object?[]? ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) => throw new NotImplementedException();
}
internal class PreviewIndicatorTransformYConverter : IMultiValueConverter
@@ -491,9 +491,9 @@ internal class PreviewIndicatorTransformYConverter : IMultiValueConverter
internal static double Margin => 2.0;
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ public object? Convert(object?[]? values, Type targetType, object? parameter, CultureInfo culture)
{
- if (values.Length >= 7
+ if (values?.Length >= 7
&& values[0] is double ratingBarButtonActualHeight
&& values[1] is double previewValueActualHeight
&& values[2] is Orientation ratingBarOrientation
@@ -531,6 +531,6 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
return 1.0;
}
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
+ public object?[]? ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) => throw new NotImplementedException();
}
}
diff --git a/src/MaterialDesignThemes.Wpf/ResourceDictionaryExtensions.g.cs b/src/MaterialDesignThemes.Wpf/ResourceDictionaryExtensions.g.cs
index 0bbf247c4b..e80cc45778 100644
--- a/src/MaterialDesignThemes.Wpf/ResourceDictionaryExtensions.g.cs
+++ b/src/MaterialDesignThemes.Wpf/ResourceDictionaryExtensions.g.cs
@@ -1,6 +1,6 @@
//------------------------------------------------------------------------------
//
-// This code was generated by mdresgen.
+// This code was generated by MaterialDesignToolkit.ResourceGeneration.
//
//------------------------------------------------------------------------------
diff --git a/src/MaterialDesignThemes.Wpf/TabAssist.cs b/src/MaterialDesignThemes.Wpf/TabAssist.cs
index 2dd368738f..1a2b3e7058 100644
--- a/src/MaterialDesignThemes.Wpf/TabAssist.cs
+++ b/src/MaterialDesignThemes.Wpf/TabAssist.cs
@@ -27,15 +27,15 @@ public static void SetHeaderPanelMargin(DependencyObject element, Thickness valu
=> element.SetValue(HeaderPanelMarginProperty, value);
public static Thickness GetHeaderPanelMargin(DependencyObject element)
- => (Thickness) element.GetValue(HeaderPanelMarginProperty);
+ => (Thickness)element.GetValue(HeaderPanelMarginProperty);
- internal static Visibility GetBindableIsItemsHost(DependencyObject obj)
+ public static Visibility GetBindableIsItemsHost(DependencyObject obj)
=> (Visibility)obj.GetValue(BindableIsItemsHostProperty);
- internal static void SetBindableIsItemsHost(DependencyObject obj, Visibility value)
+ public static void SetBindableIsItemsHost(DependencyObject obj, Visibility value)
=> obj.SetValue(BindableIsItemsHostProperty, value);
- internal static readonly DependencyProperty BindableIsItemsHostProperty =
+ public static readonly DependencyProperty BindableIsItemsHostProperty =
DependencyProperty.RegisterAttached("BindableIsItemsHost", typeof(Visibility), typeof(TabAssist), new PropertyMetadata(Visibility.Collapsed, OnBindableIsItemsHostChanged));
private static void OnBindableIsItemsHostChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
@@ -45,4 +45,13 @@ private static void OnBindableIsItemsHostChanged(DependencyObject d, DependencyP
panel.IsItemsHost = (Visibility)e.NewValue == Visibility.Visible;
}
}
+
+ public static Cursor GetTabHeaderCursor(DependencyObject obj)
+ => (Cursor)obj.GetValue(TabHeaderCursorProperty);
+
+ public static void SetTabHeaderCursor(DependencyObject obj, Cursor value)
+ => obj.SetValue(TabHeaderCursorProperty, value);
+
+ public static readonly DependencyProperty TabHeaderCursorProperty =
+ DependencyProperty.RegisterAttached("TabHeaderCursor", typeof(Cursor), typeof(TabAssist), new PropertyMetadata(Cursors.Hand));
}
diff --git a/src/MaterialDesignThemes.Wpf/Theme.g.cs b/src/MaterialDesignThemes.Wpf/Theme.g.cs
index 77720d50fe..d6cdffd3a6 100644
--- a/src/MaterialDesignThemes.Wpf/Theme.g.cs
+++ b/src/MaterialDesignThemes.Wpf/Theme.g.cs
@@ -1,6 +1,6 @@
//------------------------------------------------------------------------------
//
-// This code was generated by mdresgen.
+// This code was generated by MaterialDesignToolkit.ResourceGeneration.
//
//------------------------------------------------------------------------------
diff --git a/src/MaterialDesignThemes.Wpf/ThemeExtensions.g.cs b/src/MaterialDesignThemes.Wpf/ThemeExtensions.g.cs
index 366f190e7e..a304456e89 100644
--- a/src/MaterialDesignThemes.Wpf/ThemeExtensions.g.cs
+++ b/src/MaterialDesignThemes.Wpf/ThemeExtensions.g.cs
@@ -1,6 +1,6 @@
//------------------------------------------------------------------------------
//
-// This code was generated by mdresgen.
+// This code was generated by MaterialDesignToolkit.ResourceGeneration.
//
//------------------------------------------------------------------------------
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesign3.NavigationDrawer.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesign3.NavigationDrawer.xaml
index eba55a14d6..6eb09a0efa 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesign3.NavigationDrawer.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesign3.NavigationDrawer.xaml
@@ -9,7 +9,7 @@
-
+
@@ -130,7 +130,7 @@
-
+
@@ -145,5 +145,4 @@
-
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesign3.ToggleButton.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesign3.ToggleButton.xaml
index ce404327f7..b4bb3e3da4 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesign3.ToggleButton.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesign3.ToggleButton.xaml
@@ -331,7 +331,7 @@
@@ -653,7 +653,7 @@
-
+
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Button.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Button.xaml
index 6a9258124a..a0cd5a8cde 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Button.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Button.xaml
@@ -52,7 +52,7 @@
CornerRadius="{Binding Path=(wpf:ButtonAssist.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ElevationAssist.Elevation), Converter={x:Static converters:ShadowConverter.Instance}}" />
-
-
-
-
+
+
+
+
@@ -87,10 +87,10 @@
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
-
-
-
-
+
+
+
+
@@ -183,7 +183,7 @@
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{Binding Path=(wpf:ButtonAssist.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}" />
-
-
-
-
+
+
+
+
@@ -217,10 +217,10 @@
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
-
-
-
-
+
+
+
+
@@ -341,7 +341,7 @@
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{Binding Path=(wpf:ButtonAssist.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}" />
-
-
-
-
+
+
+
+
@@ -375,10 +375,10 @@
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
-
-
-
-
+
+
+
+
@@ -386,7 +386,6 @@
-
@@ -474,8 +473,8 @@
@@ -760,8 +759,8 @@
@@ -803,10 +802,10 @@
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
-
-
-
-
+
+
+
+
@@ -864,5 +863,4 @@
-
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Calendar.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Calendar.xaml
index c9d8698e69..6c8056d1e2 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Calendar.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Calendar.xaml
@@ -2,6 +2,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters"
xmlns:globalization="clr-namespace:System.Globalization;assembly=mscorlib"
+ xmlns:controls="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
+ xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
-
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ColorPicker.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ColorPicker.xaml
index c688492962..e80af1b037 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ColorPicker.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ColorPicker.xaml
@@ -1,7 +1,7 @@
@@ -177,12 +177,12 @@
- 1
+ 1
- 1
+ 1
@@ -241,12 +241,12 @@
- 1
+ 1
- 1
+ 1
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml
index 6b89e3d283..c46fd94963 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml
@@ -12,7 +12,7 @@
-
+
AllowCollapse
@@ -189,11 +189,11 @@
-
+
-
+
-
+
@@ -241,15 +241,15 @@
-
+
-
+
-
+
@@ -260,14 +260,14 @@
-
+
-
+
@@ -373,7 +373,7 @@
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
IsHitTestVisible="False"
- VerticalAlignment="Center"/>
+ VerticalAlignment="Center" />
-
+
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.ComboBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.ComboBox.xaml
index 66428678f5..49840244c0 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.ComboBox.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.ComboBox.xaml
@@ -22,7 +22,7 @@
-
+
@@ -63,13 +63,13 @@
-
+
-
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.xaml
index 161e0d4013..9500b87266 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.xaml
@@ -111,7 +111,7 @@
HorizontalOffset="-6"
IsOpen="True"
Placement="RelativePoint"
- PlacementTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridCell}}}"
+ PlacementTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridCell}}, FallbackValue={x:Null}}"
PopupAnimation="Fade"
VerticalOffset="-6">
@@ -381,8 +381,8 @@
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
+ Template="{Binding ValidationErrorTemplate, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}},FallbackValue={x:Null}}"
+ Visibility="{Binding (Validation.HasError), Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}, FallbackValue=Collapsed}" />
+ Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}, FallbackValue=Visible}" />
@@ -453,7 +453,7 @@
-
+
@@ -501,14 +501,14 @@
-
+ Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}, FallbackValue=Visible}" />
+ Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}, FallbackValue=Visible}">
-
+
-
+
@@ -191,5 +191,4 @@
-
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DialogHost.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DialogHost.xaml
index 52fffbdc88..01fd9a3121 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DialogHost.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DialogHost.xaml
@@ -1,10 +1,11 @@
+ xmlns:convertersInternal="clr-namespace:MaterialDesignThemes.Wpf.Converters.Internal"
+ xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
+
@@ -169,7 +168,6 @@
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
-
@@ -191,7 +189,7 @@
-
@@ -387,7 +388,7 @@
-
+
@@ -401,7 +402,7 @@
-
+
-
+
+
@@ -511,12 +513,11 @@
-
-
+
@@ -540,7 +541,6 @@
-
-
@@ -835,7 +834,7 @@
FontStretch="{TemplateBinding FontStretch}"
FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}"
- GroupName="{Binding Name, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"
+ GroupName="{Binding Name, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}, FallbackValue={x:Null}}"
IsChecked="{Binding IsSelected, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay}"
Style="{StaticResource MaterialDesignChoiceChipPrimaryRadioButton}" />
@@ -862,7 +861,7 @@
FontStretch="{TemplateBinding FontStretch}"
FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}"
- GroupName="{Binding Name, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"
+ GroupName="{Binding Name, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}, FallbackValue={x:Null}}"
IsChecked="{Binding IsSelected, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay}"
Style="{StaticResource MaterialDesignChoiceChipSecondaryRadioButton}" />
@@ -889,7 +888,7 @@
FontStretch="{TemplateBinding FontStretch}"
FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}"
- GroupName="{Binding Name, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"
+ GroupName="{Binding Name, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}, FallbackValue={x:Null}}"
IsChecked="{Binding IsSelected, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay}"
Style="{StaticResource MaterialDesignChoiceChipOutlineRadioButton}" />
@@ -916,7 +915,7 @@
FontStretch="{TemplateBinding FontStretch}"
FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}"
- GroupName="{Binding Name, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"
+ GroupName="{Binding Name, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}, FallbackValue={x:Null}}"
IsChecked="{Binding IsSelected, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay}"
Style="{StaticResource MaterialDesignChoiceChipPrimaryOutlineRadioButton}" />
@@ -943,7 +942,7 @@
FontStretch="{TemplateBinding FontStretch}"
FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}"
- GroupName="{Binding Name, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"
+ GroupName="{Binding Name, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}, FallbackValue={x:Null}}"
IsChecked="{Binding IsSelected, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay}"
Style="{StaticResource MaterialDesignChoiceChipSecondaryOutlineRadioButton}" />
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.NumericUpDown.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.NumericUpDown.xaml
index 67ab6ec796..5df54ef2aa 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.NumericUpDown.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.NumericUpDown.xaml
@@ -8,7 +8,6 @@
-
-
-
-
+
+
@@ -188,7 +188,7 @@
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="{TemplateBinding UseLayoutRounding}"
VerticalScrollBarVisibility="Hidden"
- wpf:ScrollViewerAssist.BubbleVerticalScroll="True"/>
+ wpf:ScrollViewerAssist.BubbleVerticalScroll="True" />
-
+
@@ -596,7 +596,7 @@
-
+
-
-
+
+
@@ -659,7 +659,6 @@
-
@@ -787,7 +786,7 @@
UseLayoutRounding="{TemplateBinding UseLayoutRounding}"
VerticalScrollBarVisibility="Hidden"
Visibility="{Binding ElementName=PasswordContentGrid, Path=(wpf:PasswordBoxAssist.IsPasswordRevealed), Converter={x:Static converters:BooleanToVisibilityConverter.NotCollapsedInstance}}"
- wpf:ScrollViewerAssist.BubbleVerticalScroll="True"/>
+ wpf:ScrollViewerAssist.BubbleVerticalScroll="True" />
-
@@ -1129,7 +1127,7 @@
-
+
@@ -1217,5 +1215,4 @@
-
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml
index f7d21bd418..e65875261b 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml
@@ -80,6 +80,7 @@
+
@@ -108,7 +109,7 @@
@@ -178,7 +179,7 @@
+
@@ -272,17 +274,18 @@
Clip="{Binding ElementName=GeometryEllipse, Path=RenderedGeometry}"
ClipToBounds="True"
Focusable="False"
- SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
-
-
-
-
-
-
-
+ SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
+
+
+
+
+
+
+ PopupAnimation="{TemplateBinding PopupAnimation}">
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ProgressBar.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ProgressBar.xaml
index 4ad30d2d68..7fbe3d00a9 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ProgressBar.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ProgressBar.xaml
@@ -184,26 +184,26 @@
StrokeThickness="3">
-
-
+
+
-
+
-
+
-
+
-
+
-
+
@@ -212,7 +212,9 @@
-
+
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.RadioButton.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.RadioButton.xaml
index 00df04c542..8bca63e894 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.RadioButton.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.RadioButton.xaml
@@ -1,10 +1,10 @@
-
-
-
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Snackbar.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Snackbar.xaml
index 97c582c8f8..657831e36b 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Snackbar.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Snackbar.xaml
@@ -88,18 +88,18 @@
ContentStringFormat="{TemplateBinding ActionContentStringFormat}"
ContentTemplate="{TemplateBinding ActionContentTemplate}"
ContentTemplateSelector="{TemplateBinding ActionContentTemplateSelector}"
- Style="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wpf:Snackbar}}, Path=ActionButtonStyle}"
+ Style="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wpf:Snackbar}}, Path=ActionButtonStyle, FallbackValue={x:Null}}"
Visibility="{TemplateBinding ActionContent, Converter={x:Static converters:NullableToVisibilityConverter.CollapsedInstance}}">
-
-
-
+
+
+
-
@@ -223,5 +223,4 @@
-
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TabControl.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TabControl.xaml
index b97a2f48d4..d6279585d8 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TabControl.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TabControl.xaml
@@ -23,7 +23,7 @@
@@ -486,7 +489,7 @@
@@ -557,7 +560,7 @@
-
+
@@ -594,7 +597,6 @@
-
@@ -669,7 +671,6 @@
Visibility="Collapsed" />
-
-
+
-
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TimePicker.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TimePicker.xaml
index cb2d9de90c..5f09d6a8ef 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TimePicker.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TimePicker.xaml
@@ -35,7 +35,7 @@
-
+
@@ -202,5 +202,4 @@
-
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToggleButton.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToggleButton.xaml
index 66b5d16d89..52e85b15ca 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToggleButton.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToggleButton.xaml
@@ -5,7 +5,7 @@
-
+
-
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeListView.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeListView.xaml
index c2f8a0afa4..0f13b84415 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeListView.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeListView.xaml
@@ -98,8 +98,8 @@
-
-
+
+
@@ -107,7 +107,7 @@
-
+
@@ -234,7 +234,7 @@
-
+
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeView.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeView.xaml
index 644d3a6f18..9b5cb01956 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeView.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TreeView.xaml
@@ -165,8 +165,8 @@
-
-
+
+
@@ -379,7 +379,7 @@
-
+
diff --git a/src/MaterialDesignThemes.Wpf/TreeListView.cs b/src/MaterialDesignThemes.Wpf/TreeListView.cs
index e5c778773c..8f907f73b9 100644
--- a/src/MaterialDesignThemes.Wpf/TreeListView.cs
+++ b/src/MaterialDesignThemes.Wpf/TreeListView.cs
@@ -51,24 +51,24 @@ protected override DependencyObject GetContainerForItemOverride()
protected override bool IsItemItsOwnContainerOverride(object? item)
=> item is TreeListViewItem;
- protected override void PrepareContainerForItemOverride(DependencyObject element, object? item)
- {
- base.PrepareContainerForItemOverride(element, item);
+ //protected override void PrepareContainerForItemOverride(DependencyObject element, object? item)
+ //{
+ // base.PrepareContainerForItemOverride(element, item);
- if (element is TreeListViewItem treeListViewItem)
- {
- int level = 0;
- bool isExpanded = false;
- int index = ItemContainerGenerator.IndexFromContainer(treeListViewItem);
- if (index >= 0 && InternalItemsSource is { } itemsSource)
- {
- level = itemsSource.GetLevel(index);
- isExpanded = itemsSource.GetIsExpanded(index);
- }
+ // if (element is TreeListViewItem treeListViewItem)
+ // {
+ // int level = 0;
+ // bool isExpanded = false;
+ // int index = ItemContainerGenerator.IndexFromContainer(treeListViewItem);
+ // if (index >= 0 && InternalItemsSource is { } itemsSource)
+ // {
+ // level = itemsSource.GetLevel(index);
+ // isExpanded = itemsSource.GetIsExpanded(index);
+ // }
- treeListViewItem.PrepareTreeListViewItem(item, this, level, isExpanded);
- }
- }
+ // treeListViewItem.PrepareTreeListViewItem(item, this, level, isExpanded);
+ // }
+ //}
protected override void ClearContainerForItemOverride(DependencyObject element, object item)
{
@@ -86,11 +86,19 @@ internal void ItemExpandedChanged(TreeListViewItem item)
int index = ItemContainerGenerator.IndexFromContainer(item);
//Issue 3572
if (index < 0) return;
- var children = item.GetChildren().ToList();
- bool isExpanded = item.IsExpanded;
+ var isExpanded = item.IsExpanded;
+ var internalIsExpanded = itemsSource.GetIsExpanded(index);
+
+ if (internalIsExpanded == isExpanded)
+ {
+ return;
+ }
+
itemsSource.SetIsExpanded(index, isExpanded);
+
if (isExpanded)
{
+ var children = item.GetChildren().ToList();
int parentLevel = itemsSource.GetLevel(index);
for (int i = 0; i < children.Count; i++)
{
diff --git a/src/MaterialDesignThemes.Wpf/TreeListViewItem.cs b/src/MaterialDesignThemes.Wpf/TreeListViewItem.cs
index 8aeab1aee8..3c42c8285b 100644
--- a/src/MaterialDesignThemes.Wpf/TreeListViewItem.cs
+++ b/src/MaterialDesignThemes.Wpf/TreeListViewItem.cs
@@ -146,7 +146,18 @@ public override void OnApplyTemplate()
void OnTemplateChanged(object? sender, EventArgs e)
{
- PrepareTreeListViewItem(Content, TreeListView!, Level, IsExpanded);
+ int level = 0;
+ bool isExpanded = false;
+ int index = TreeListView!.ItemContainerGenerator.IndexFromContainer(this);
+
+
+ if (index >= 0 && TreeListView.InternalItemsSource is { } itemsSource)
+ {
+ level = itemsSource.GetLevel(index);
+ isExpanded = itemsSource.GetIsExpanded(index);
+ }
+
+ PrepareTreeListViewItem(Content, TreeListView, level, isExpanded);
}
}
}
diff --git a/src/MaterialDesignThemes.Wpf/UpDownBase.cs b/src/MaterialDesignThemes.Wpf/UpDownBase.cs
index e3ecb89407..0617eb7824 100644
--- a/src/MaterialDesignThemes.Wpf/UpDownBase.cs
+++ b/src/MaterialDesignThemes.Wpf/UpDownBase.cs
@@ -118,7 +118,7 @@ private static void OnNumericValueChanged(DependencyObject d, DependencyProperty
if (upDownBase._textBoxField is { } textBox)
{
- textBox.Text = e.NewValue.ToString();
+ textBox.Text = Convert.ToString(e.NewValue, CultureInfo.CurrentCulture);
}
upDownBase.UpdateDecreaseButtonEnabled();
@@ -201,7 +201,10 @@ public override void OnApplyTemplate()
if (_decreaseButton != null)
_decreaseButton.Click -= DecreaseButtonOnClick;
if (_textBoxField != null)
- _textBoxField.TextChanged -= OnTextBoxFocusLost;
+ {
+ _textBoxField.TextChanged -= OnTextBoxTextChanged;
+ _textBoxField.LostFocus -= OnTextBoxLostFocus;
+ }
base.OnApplyTemplate();
@@ -219,22 +222,29 @@ public override void OnApplyTemplate()
if (_textBoxField != null)
{
- _textBoxField.LostFocus += OnTextBoxFocusLost;
- _textBoxField.Text = Value?.ToString();
+ _textBoxField.TextChanged += OnTextBoxTextChanged;
+ _textBoxField.LostFocus += OnTextBoxLostFocus;
+ _textBoxField.Text = Convert.ToString(Value, CultureInfo.CurrentCulture);
}
}
- private void OnTextBoxFocusLost(object sender, EventArgs e)
+ private void OnTextBoxLostFocus(object sender, EventArgs e)
+ {
+ if (_textBoxField is { } textBoxField)
+ {
+ textBoxField.Text = Convert.ToString(Value, CultureInfo.CurrentCulture);
+ }
+ }
+
+ private void OnTextBoxTextChanged(object sender, EventArgs e)
{
if (_textBoxField is { } textBoxField)
{
- if (TryParse(textBoxField.Text, CultureInfo.CurrentUICulture, out T? value))
+ if (TryParse(textBoxField.Text, CultureInfo.CurrentCulture, out T? value))
{
SetCurrentValue(ValueProperty, ClampValue(value));
}
- //NB: Because setting ValueProperty will coerce the value, we re-assign back to the textbox here.
- textBoxField.Text = Value?.ToString();
}
}
diff --git a/src/MaterialDesignToolkit.ResourceGeneration/Brushes.cs b/src/MaterialDesignToolkit.ResourceGeneration/Brushes.cs
index ca1354b481..212aadb789 100644
--- a/src/MaterialDesignToolkit.ResourceGeneration/Brushes.cs
+++ b/src/MaterialDesignToolkit.ResourceGeneration/Brushes.cs
@@ -482,7 +482,7 @@ void WriteBrush(Brush brush, string name)
{{indent}}{{indent}}{
{{indent}}{{indent}}{{indent}}IVisualElement textBlock = await panel.GetElement("[Text=\"{{name}}\"]");
{{indent}}{{indent}}{{indent}}Color? textBlockBackground = await textBlock.GetBackgroundColor();
- {{indent}}{{indent}}{{indent}}Assert.Equal(await GetResourceColor("{{brush.Name}}"), textBlockBackground);
+ {{indent}}{{indent}}{{indent}}await Assert.That(textBlockBackground).IsEqualTo(await GetResourceColor("{{brush.Name}}"));
{{indent}}{{indent}}}
""");
}
diff --git a/tests/MaterialDesignColors.Wpf.Tests/ColorAssistTests.cs b/tests/MaterialDesignColors.Wpf.Tests/ColorAssistTests.cs
index 47b0bf905a..919c47035a 100644
--- a/tests/MaterialDesignColors.Wpf.Tests/ColorAssistTests.cs
+++ b/tests/MaterialDesignColors.Wpf.Tests/ColorAssistTests.cs
@@ -1,13 +1,12 @@
using System.Windows.Media;
using MaterialDesignColors.ColorManipulation;
-using Xunit;
namespace MaterialDesignColors.Wpf.Tests;
public class ColorAssistTests
{
- [Fact]
- public void EnsureContrastRatio_AdjustsColor()
+ [Test]
+ public async Task EnsureContrastRatio_AdjustsColor()
{
var background = Color.FromRgb(0xFA, 0xFA, 0xFA);
var foreground = Color.FromRgb(0xFF, 0xC1, 0x07);
@@ -15,7 +14,7 @@ public void EnsureContrastRatio_AdjustsColor()
var adjusted = foreground.EnsureContrastRatio(background, 3.0f);
double contrastRatio = adjusted.ContrastRatio(background);
- Assert.True(contrastRatio >= 2.9);
- Assert.True(contrastRatio <= 3.1);
+ await Assert.That(contrastRatio).IsGreaterThanOrEqualTo(2.9);
+ await Assert.That(contrastRatio).IsLessThanOrEqualTo(3.1);
}
}
diff --git a/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj b/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj
index 66ee05538b..079e511042 100644
--- a/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj
+++ b/tests/MaterialDesignColors.Wpf.Tests/MaterialDesignColors.Wpf.Tests.csproj
@@ -1,9 +1,12 @@
- net472;net6.0-windows;net8.0-windows
+ net472;net8.0-windows
MaterialDesignColors.Wpf.Tests
MaterialDesignColors.Wpf.Tests
+ true
+ Exe
+ true
@@ -25,9 +28,9 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/tests/MaterialDesignColors.Wpf.Tests/ResourceProviderFixture.cs b/tests/MaterialDesignColors.Wpf.Tests/ResourceProviderFixture.cs
index d54a25183a..4f3eeac307 100644
--- a/tests/MaterialDesignColors.Wpf.Tests/ResourceProviderFixture.cs
+++ b/tests/MaterialDesignColors.Wpf.Tests/ResourceProviderFixture.cs
@@ -1,65 +1,62 @@
-using Shouldly;
-using Xunit;
-
-namespace MaterialDesignColors.Wpf.Fixture;
+namespace MaterialDesignColors.Wpf.Tests;
public class ResourceProviderFixture
{
- [Fact]
- public void ExcludesBlack()
+ [Test]
+ public async Task ExcludesBlack()
{
SwatchesProvider swatchesProvider = new ();
bool containsBlack = swatchesProvider.Swatches.Any(
swatch => string.Compare(swatch.Name, "Black", StringComparison.InvariantCultureIgnoreCase) == 0);
- containsBlack.ShouldBe(false);
+ await Assert.That(containsBlack).IsFalse();
}
- [Fact]
- public void IncludesGrey()
+ [Test]
+ public async Task IncludesGrey()
{
SwatchesProvider swatchesProvider = new ();
bool containsBlack = swatchesProvider.Swatches.Any(
swatch => string.Compare(swatch.Name, "Grey", StringComparison.InvariantCultureIgnoreCase) == 0);
- containsBlack.ShouldBe(true);
+ await Assert.That(containsBlack).IsTrue();
}
- [Fact]
- public void BrownHasNoSecondary()
+ [Test]
+ public async Task BrownHasNoSecondary()
{
SwatchesProvider swatchesProvider = new ();
var brownSwatch = swatchesProvider.Swatches.Single(
swatch => swatch.Name == "brown");
- brownSwatch.SecondaryHues.ShouldNotBeNull();
- brownSwatch.SecondaryHues.Count.ShouldBe(0);
+ await Assert.That(brownSwatch.SecondaryHues).IsNotNull();
+ await Assert.That(brownSwatch.SecondaryHues.Count).IsEqualTo(0);
}
- [Fact]
- public void BrownHasPrimaries()
+ [Test]
+ public async Task BrownHasPrimaries()
{
SwatchesProvider swatchesProvider = new ();
var brownSwatch = swatchesProvider.Swatches.Single(
swatch => swatch.Name == "brown");
- brownSwatch.PrimaryHues.ShouldNotBeNull();
- brownSwatch.PrimaryHues.Count.ShouldBe(10);
+ await Assert.That(brownSwatch.PrimaryHues).IsNotNull();
+ await Assert.That(brownSwatch.PrimaryHues.Count).IsEqualTo(10);
}
- [Fact]
- public void IndigoHasSecondaries()
+ [Test]
+ public async Task IndigoHasSecondaries()
{
SwatchesProvider swatchesProvider = new ();
var brownSwatch = swatchesProvider.Swatches.Single(
swatch => swatch.Name == "indigo");
- brownSwatch.SecondaryHues.ShouldNotBeNull();
- brownSwatch.SecondaryHues.Count.ShouldBe(4);
+ await Assert.That(brownSwatch.SecondaryHues).IsNotNull();
+ await Assert.That(brownSwatch.SecondaryHues.Count).IsEqualTo(4);
}
}
diff --git a/tests/MaterialDesignThemes.UITests/AllStyles.cs b/tests/MaterialDesignThemes.UITests/AllStyles.cs
index 2710e4b0fe..5d3c6c0f01 100644
--- a/tests/MaterialDesignThemes.UITests/AllStyles.cs
+++ b/tests/MaterialDesignThemes.UITests/AllStyles.cs
@@ -1,40 +1,35 @@
-using System.Reflection;
-using MaterialDesignColors;
+using MaterialDesignColors;
namespace MaterialDesignThemes.UITests;
public class AllStyles : TestBase
{
- public AllStyles(ITestOutputHelper output)
- : base(output)
- { }
-
- [Theory]
- [InlineData("Button", "MaterialDesignRaisedButton")]
- [InlineData("Calendar", "MaterialDesignCalendarPortrait")]
- [InlineData("CheckBox", "MaterialDesignCheckBox")]
- [InlineData("ComboBox", "MaterialDesignComboBox")]
- [InlineData("DataGrid", "MaterialDesignDataGrid")]
- [InlineData("DatePicker", "MaterialDesignDatePicker")]
- [InlineData("Expander", "MaterialDesignExpander")]
- [InlineData("GridSplitter", "MaterialDesignGridSplitter")]
- [InlineData("GroupBox", "MaterialDesignGroupBox")]
- [InlineData("Label", "MaterialDesignLabel")]
- [InlineData("ListBox", "MaterialDesignListBox")]
- [InlineData("ListView", "MaterialDesignListView")]
- [InlineData("Menu", "MaterialDesignMenu")]
- [InlineData("PasswordBox", "MaterialDesignPasswordBox")]
- [InlineData("ProgressBar", "MaterialDesignLinearProgressBar")]
- [InlineData("RadioButton", "MaterialDesignRadioButton")]
- [InlineData("RichTextBox", "MaterialDesignRichTextBox")]
- [InlineData("ScrollBar", "MaterialDesignScrollBar")]
- [InlineData("ScrollViewer", "MaterialDesignScrollViewer")]
- [InlineData("Slider", "MaterialDesignSlider")]
- [InlineData("TabControl", "MaterialDesignTabControl")]
- [InlineData("TextBox", "MaterialDesignTextBox")]
- [InlineData("ToggleButton", "MaterialDesignSwitchToggleButton")]
- [InlineData("ToolBar", "MaterialDesignToolBar")]
- [InlineData("TreeView", "MaterialDesignTreeView")]
+ [Test]
+ [Arguments("Button", "MaterialDesignRaisedButton")]
+ [Arguments("Calendar", "MaterialDesignCalendarPortrait")]
+ [Arguments("CheckBox", "MaterialDesignCheckBox")]
+ [Arguments("ComboBox", "MaterialDesignComboBox")]
+ [Arguments("DataGrid", "MaterialDesignDataGrid")]
+ [Arguments("DatePicker", "MaterialDesignDatePicker")]
+ [Arguments("Expander", "MaterialDesignExpander")]
+ [Arguments("GridSplitter", "MaterialDesignGridSplitter")]
+ [Arguments("GroupBox", "MaterialDesignGroupBox")]
+ [Arguments("Label", "MaterialDesignLabel")]
+ [Arguments("ListBox", "MaterialDesignListBox")]
+ [Arguments("ListView", "MaterialDesignListView")]
+ [Arguments("Menu", "MaterialDesignMenu")]
+ [Arguments("PasswordBox", "MaterialDesignPasswordBox")]
+ [Arguments("ProgressBar", "MaterialDesignLinearProgressBar")]
+ [Arguments("RadioButton", "MaterialDesignRadioButton")]
+ [Arguments("RichTextBox", "MaterialDesignRichTextBox")]
+ [Arguments("ScrollBar", "MaterialDesignScrollBar")]
+ [Arguments("ScrollViewer", "MaterialDesignScrollViewer")]
+ [Arguments("Slider", "MaterialDesignSlider")]
+ [Arguments("TabControl", "MaterialDesignTabControl")]
+ [Arguments("TextBox", "MaterialDesignTextBox")]
+ [Arguments("ToggleButton", "MaterialDesignSwitchToggleButton")]
+ [Arguments("ToolBar", "MaterialDesignToolBar")]
+ [Arguments("TreeView", "MaterialDesignTreeView")]
public async Task LoadStyleInIsolation_CanBeLoaded(string controlName, string styleName)
{
await using var recorder = new TestRecorder(App);
@@ -57,7 +52,7 @@ public async Task LoadStyleInIsolation_CanBeLoaded(string controlName, string st
await App.Initialize(applicationResourceXaml,
Path.GetFullPath("MaterialDesignColors.dll"),
Path.GetFullPath("MaterialDesignThemes.Wpf.dll"),
- Assembly.GetExecutingAssembly().Location);
+ System.Reflection.Assembly.GetExecutingAssembly().Location);
IWindow window = await App.CreateWindow($$"""
""");
- Assert.True(await window.GetIsVisible());
+ await Assert.That(await window.GetIsVisible()).IsTrue();
recorder.Success();
}
diff --git a/tests/MaterialDesignThemes.UITests/MaterialDesignSpec.cs b/tests/MaterialDesignThemes.UITests/MaterialDesignSpec.cs
index 7247b4d8a6..4de16f29ee 100644
--- a/tests/MaterialDesignThemes.UITests/MaterialDesignSpec.cs
+++ b/tests/MaterialDesignThemes.UITests/MaterialDesignSpec.cs
@@ -17,11 +17,12 @@ public static class MaterialDesignSpec
///
public const double MinimumContrastLargeText = 3.0;
- public static void AssertContrastRatio(Color foreground, Color background, double minimumContrastRatio)
+ public static async Task AssertContrastRatio(Color foreground, Color background, double minimumContrastRatio)
{
const double tolerance = 0.1;
- var ratio = ColorAssist.ContrastRatio(foreground, background);
- Assert.True(ratio >= minimumContrastRatio - tolerance, $"Contrast ratio '{ratio}' is less than {minimumContrastRatio} with a tolerance of 0.1");
+ double ratio = ColorAssist.ContrastRatio(foreground, background);
+ await Assert.That(ratio).IsGreaterThanOrEqualTo(minimumContrastRatio - tolerance)
+ .Because($"Contrast ratio '{ratio}' is less than {minimumContrastRatio} with a tolerance of 0.1");
}
}
diff --git a/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj b/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj
index c75b048ec9..8e78308ec4 100644
--- a/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj
+++ b/tests/MaterialDesignThemes.UITests/MaterialDesignThemes.UITests.csproj
@@ -1,11 +1,14 @@
- net8.0-windows
+ net9.0-windows
false
false
true
$(NoWarn);CA1707
true
+ true
+ Exe
+ true
@@ -19,18 +22,13 @@
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
+
-
-
diff --git a/tests/MaterialDesignThemes.UITests/Samples/AutoSuggestBoxes/AutoSuggestTextBoxWithCollectionView.xaml b/tests/MaterialDesignThemes.UITests/Samples/AutoSuggestBoxes/AutoSuggestTextBoxWithCollectionView.xaml
index cba573ebb8..12076ca6d9 100644
--- a/tests/MaterialDesignThemes.UITests/Samples/AutoSuggestBoxes/AutoSuggestTextBoxWithCollectionView.xaml
+++ b/tests/MaterialDesignThemes.UITests/Samples/AutoSuggestBoxes/AutoSuggestTextBoxWithCollectionView.xaml
@@ -14,7 +14,9 @@
materialDesign:HintAssist.HelperText="Name"
materialDesign:TextFieldAssist.HasClearButton="True"
Text="{Binding AutoSuggestText, UpdateSourceTrigger=PropertyChanged}"
- Suggestions="{Binding Suggestions}">
+ Suggestions="{Binding Suggestions}"
+ SelectedItem="{Binding SelectedItem}"
+ >
BaseSuggestions { get; }
[ObservableProperty]
- private ObservableCollection _suggestions = new();
+ private ObservableCollection _suggestions = [];
[ObservableProperty]
private string? _autoSuggestText;
@@ -41,14 +41,14 @@ partial void OnAutoSuggestTextChanged(string? oldValue, string? newValue)
public AutoSuggestTextBoxWithTemplateViewModel()
{
- BaseSuggestions = new()
- {
+ BaseSuggestions =
+ [
new("Apples"),
new("Bananas"),
new("Beans"),
new("Mtn Dew"),
new("Orange"),
- };
+ ];
Suggestions = new ObservableCollection(BaseSuggestions);
}
@@ -62,9 +62,7 @@ private static bool IsMatch(string item, string currentText)
}
}
-public class SuggestionThing
+public class SuggestionThing(string name)
{
- public string Name { get; }
-
- public SuggestionThing(string name) => Name = name;
+ public string Name { get; } = name;
}
diff --git a/tests/MaterialDesignThemes.UITests/Samples/Validation/ValidationUpdates.xaml.cs b/tests/MaterialDesignThemes.UITests/Samples/Validation/ValidationUpdates.xaml.cs
index 719ead86b2..6d830021a8 100644
--- a/tests/MaterialDesignThemes.UITests/Samples/Validation/ValidationUpdates.xaml.cs
+++ b/tests/MaterialDesignThemes.UITests/Samples/Validation/ValidationUpdates.xaml.cs
@@ -1,6 +1,6 @@
using System.Collections;
using System.ComponentModel;
-using System.ComponentModel.DataAnnotations;
+using System.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
@@ -46,7 +46,7 @@ private async Task CauseErrors()
{
Error = "Some error";
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(Text)));
- await Task.Delay(100);
+ await Task.Delay(100, CancellationToken.None);
Error += " + more";
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(Text)));
}
diff --git a/tests/MaterialDesignThemes.UITests/TUnit/IsCloseToExtensions.cs b/tests/MaterialDesignThemes.UITests/TUnit/IsCloseToExtensions.cs
new file mode 100644
index 0000000000..1ae6934500
--- /dev/null
+++ b/tests/MaterialDesignThemes.UITests/TUnit/IsCloseToExtensions.cs
@@ -0,0 +1,51 @@
+using System.Numerics;
+using System.Runtime.CompilerServices;
+using TUnit.Assertions.AssertConditions;
+using TUnit.Assertions.AssertConditions.Interfaces;
+using TUnit.Assertions.AssertionBuilders;
+
+namespace MaterialDesignThemes.Tests.TUnit;
+
+public static class IsCloseToExtensions
+{
+ public static IsCloseToWrapper IsCloseTo(this IValueSource valueSource, double expected, double precision, [CallerArgumentExpression(nameof(expected))] string? doNotPopulateThisValue1 = null, [CallerArgumentExpression(nameof(precision))] string? doNotPopulateThisValue2 = null)
+ {
+ var assertionBuilder = valueSource.RegisterAssertion(new IsCloseToCondition(expected, precision)
+ , [doNotPopulateThisValue1, doNotPopulateThisValue2]);
+
+ return new IsCloseToWrapper(assertionBuilder);
+ }
+
+ public static IsCloseToWrapper IsCloseTo(this IValueSource valueSource, float expected, float precision, [CallerArgumentExpression(nameof(expected))] string? doNotPopulateThisValue1 = null, [CallerArgumentExpression(nameof(precision))] string? doNotPopulateThisValue2 = null)
+ {
+ var assertionBuilder = valueSource.RegisterAssertion(new IsCloseToCondition(expected, precision)
+ , [doNotPopulateThisValue1, doNotPopulateThisValue2]);
+
+ return new IsCloseToWrapper(assertionBuilder);
+ }
+}
+
+public class IsCloseToWrapper(InvokableAssertionBuilder invokableAssertionBuilder)
+ : InvokableValueAssertionBuilder(invokableAssertionBuilder);
+
+file class IsCloseToCondition(TActual expected, TActual tolerance) : BaseAssertCondition
+ where TActual :
+ IFloatingPoint,
+ INumberBase
+{
+ protected override string GetExpectation() => $"to be within {tolerance} of {expected}";
+
+ protected override ValueTask GetResult(
+ TActual? actualValue, Exception? exception,
+ AssertionMetadata assertionMetadata
+ )
+ {
+ if(actualValue is null)
+ return AssertionResult.Fail("received null");
+
+ TActual difference = actualValue - expected;
+ TActual absoluteDifference = TActual.Abs(difference);
+ bool isInRange = absoluteDifference <= tolerance;
+ return AssertionResult.FailIf(!isInRange, $"received {actualValue}");
+ }
+}
diff --git a/tests/MaterialDesignThemes.UITests/TestBase.cs b/tests/MaterialDesignThemes.UITests/TestBase.cs
index 66615f971c..e2aeac2535 100644
--- a/tests/MaterialDesignThemes.UITests/TestBase.cs
+++ b/tests/MaterialDesignThemes.UITests/TestBase.cs
@@ -1,7 +1,10 @@
using System.Diagnostics.CodeAnalysis;
using System.Windows.Media;
+using MaterialDesignThemes.UITests;
+using TUnit.Core.Interfaces;
+
+[assembly: ParallelLimiter]
-[assembly: CollectionBehavior(DisableTestParallelization = true)]
[assembly: GenerateHelpers(typeof(AutoSuggestBox))]
[assembly: GenerateHelpers(typeof(ColorPicker))]
[assembly: GenerateHelpers(typeof(DecimalUpDown))]
@@ -16,10 +19,15 @@
namespace MaterialDesignThemes.UITests;
-public abstract class TestBase(ITestOutputHelper output) : IAsyncLifetime
+public record SingleParallelLimit : IParallelLimit
+{
+ public int Limit => 1;
+}
+
+public abstract class TestBase()
{
protected bool AttachedDebuggerToRemoteProcess { get; set; } = true;
- protected ITestOutputHelper Output { get; } = output ?? throw new ArgumentNullException(nameof(output));
+ protected static TextWriter Output => TestContext.Current?.OutputWriter ?? throw new InvalidOperationException("Could not find output writer");
[NotNull]
protected IApp? App { get; set; }
@@ -46,7 +54,8 @@ protected async Task LoadUserControl(Type userControlType)
return await App.CreateWindowWithUserControl(userControlType);
}
- public async Task InitializeAsync() =>
+ [Before(Test)]
+ public async ValueTask InitializeAsync() =>
App = await XamlTest.App.StartRemote(new AppOptions
{
#if !DEBUG
@@ -55,5 +64,7 @@ public async Task InitializeAsync() =>
AllowVisualStudioDebuggerAttach = AttachedDebuggerToRemoteProcess,
LogMessage = Output.WriteLine
});
- public async Task DisposeAsync() => await App.DisposeAsync();
+
+ [After(Test)]
+ public async ValueTask DisposeAsync() => await App.DisposeAsync();
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs
index 5d4c7494c6..f1302b56bf 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs
@@ -1,20 +1,17 @@
-using System.Collections;
using System.ComponentModel;
using MaterialDesignThemes.UITests.Samples.AutoSuggestBoxes;
using MaterialDesignThemes.UITests.Samples.AutoSuggestTextBoxes;
-using Xunit.Sdk;
-
+using TUnit.Core.Exceptions;
namespace MaterialDesignThemes.UITests.WPF.AutoSuggestBoxes;
public class AutoSuggestBoxTests : TestBase
{
- public AutoSuggestBoxTests(ITestOutputHelper output)
- : base(output)
+ public AutoSuggestBoxTests()
{
- AttachedDebuggerToRemoteProcess = true;
+ AttachedDebuggerToRemoteProcess = false;
}
- [Fact]
+ [Test]
public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggestions()
{
await using var recorder = new TestRecorder(App);
@@ -30,8 +27,8 @@ public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggesti
//Assert
- Assert.True(await suggestBox.GetIsSuggestionOpen());
- Assert.True(await popup.GetIsOpen());
+ await Assert.That(await suggestBox.GetIsSuggestionOpen()).IsTrue();
+ await Assert.That(await popup.GetIsOpen()).IsTrue();
//Validates these elements are found
await AssertExists(suggestionListBox, "Bananas");
@@ -45,7 +42,7 @@ public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggesti
recorder.Success();
}
- [Fact]
+ [Test]
public async Task CanChoiceItem_FromTheSuggestions_AssertTheTextUpdated()
{
await using var recorder = new TestRecorder(App);
@@ -60,8 +57,8 @@ public async Task CanChoiceItem_FromTheSuggestions_AssertTheTextUpdated()
await suggestBox.SendInput(new KeyboardInput("B"));
//Assert
- Assert.True(await suggestBox.GetIsSuggestionOpen());
- Assert.True(await popup.GetIsOpen());
+ await Assert.That(await suggestBox.GetIsSuggestionOpen()).IsTrue();
+ await Assert.That(await popup.GetIsOpen()).IsTrue();
double? lastHeight = null;
await Wait.For(async () =>
@@ -72,7 +69,7 @@ await Wait.For(async () =>
lastHeight = currentHeight;
if (!rv)
{
- await Task.Delay(100);
+ await Task.Delay(100, TestContext.Current!.CancellationToken);
}
return rv;
});
@@ -83,16 +80,16 @@ await Wait.For(async () =>
await bananas.LeftClick();
// Wait for the text to be updated
- await Task.Delay(50);
+ await Task.Delay(50, TestContext.Current!.CancellationToken);
var suggestBoxText = await suggestBox.GetText();
//Validate that the current text is the same as the selected item
- Assert.Equal("Bananas", suggestBoxText);
+ await Assert.That(suggestBoxText).IsEqualTo("Bananas");
recorder.Success();
}
- [Fact]
+ [Test]
public async Task CanFilterItems_WithCollectionView_FiltersSuggestions()
{
await using var recorder = new TestRecorder(App);
@@ -109,8 +106,8 @@ public async Task CanFilterItems_WithCollectionView_FiltersSuggestions()
//Assert
- Assert.True(await suggestBox.GetIsSuggestionOpen());
- Assert.True(await popup.GetIsOpen());
+ await Assert.That(await suggestBox.GetIsSuggestionOpen()).IsTrue();
+ await Assert.That(await popup.GetIsOpen()).IsTrue();
//Validates these elements are found
await AssertExists(suggestionListBox, "Bananas");
@@ -124,7 +121,7 @@ public async Task CanFilterItems_WithCollectionView_FiltersSuggestions()
recorder.Success();
}
- [Fact]
+ [Test]
[Description("Issue 3761")]
public async Task AutoSuggestBox_MovesFocusToNextElement_WhenPopupIsClosed()
{
@@ -145,22 +142,22 @@ public async Task AutoSuggestBox_MovesFocusToNextElement_WhenPopupIsClosed()
// Act
await suggestBox.MoveKeyboardFocus();
- await Task.Delay(50);
+ await Task.Delay(50, TestContext.Current!.CancellationToken);
await suggestBox.SendInput(new KeyboardInput("B")); // Open the popup
- await Task.Delay(50);
+ await Task.Delay(50, TestContext.Current.CancellationToken);
await suggestBox.SendInput(new KeyboardInput(Key.Escape)); // Close the popup
- await Task.Delay(50);
+ await Task.Delay(50, TestContext.Current.CancellationToken);
await suggestBox.SendInput(new KeyboardInput(Key.Tab)); // Press TAB to focus the next element
- await Task.Delay(50);
+ await Task.Delay(50, TestContext.Current.CancellationToken);
// Assert
- Assert.False(await suggestBox.GetIsFocused());
- Assert.True(await nextTextBox.GetIsFocused());
+ await Assert.That(await suggestBox.GetIsFocused()).IsFalse();
+ await Assert.That(await nextTextBox.GetIsFocused()).IsTrue();
recorder.Success();
}
- [Fact]
+ [Test]
[Description("Issue 3815")]
public async Task AutoSuggestBox_KeysUpAndDown_WrapAround()
{
@@ -176,7 +173,7 @@ public async Task AutoSuggestBox_KeysUpAndDown_WrapAround()
//Act & Assert
await suggestBox.MoveKeyboardFocus();
await suggestBox.SendInput(new KeyboardInput("e"));
- await Task.Delay(delay);
+ await Task.Delay(delay, TestContext.Current!.CancellationToken);
static int? GetSuggestionCount(AutoSuggestBox autoSuggestBox)
{
@@ -188,17 +185,51 @@ public async Task AutoSuggestBox_KeysUpAndDown_WrapAround()
//Assert that initially the first item is selected
int selectedIndex = await suggestionListBox.GetSelectedIndex();
- Assert.Equal(0, selectedIndex);
- await Task.Delay(delay);
+ await Assert.That(selectedIndex).IsEqualTo(0);
+ await Task.Delay(delay, TestContext.Current.CancellationToken);
//Assert that the last item is selected after pressing ArrowUp
await suggestBox.SendInput(new KeyboardInput(Key.Up));
- Assert.Equal(itemCount - 1, await suggestionListBox.GetSelectedIndex());
- await Task.Delay(delay);
+ await Assert.That(await suggestionListBox.GetSelectedIndex()).IsEqualTo(itemCount - 1);
+ await Task.Delay(delay, TestContext.Current.CancellationToken);
//Assert that the first item is selected after pressing ArrowDown
await suggestBox.SendInput(new KeyboardInput(Key.Down));
- Assert.Equal(0, await suggestionListBox.GetSelectedIndex());
+ await Assert.That(await suggestionListBox.GetSelectedIndex()).IsEqualTo(0);
+
+ recorder.Success();
+ }
+
+ [Test]
+ [Description("Issue 3845")]
+ public async Task AutoSuggestBox_SelectingAnItem_SetsSelectedItem()
+ {
+ await using var recorder = new TestRecorder(App);
+
+ //Arrange
+ IVisualElement userControl = await LoadUserControl();
+ IVisualElement suggestBox = await userControl.GetElement();
+ IVisualElement popup = await suggestBox.GetElement();
+ IVisualElement suggestionListBox = await popup.GetElement();
+
+ //Act
+ await suggestBox.MoveKeyboardFocus();
+ await Task.Delay(50);
+ await suggestBox.SendKeyboardInput($"B{Key.Down}{Key.Enter}");
+ await Task.Delay(50);
+
+ //Assert
+ string? selectedItem = (await suggestBox.GetSelectedItem()) as string;
+ await Assert.That(selectedItem).IsEqualTo("Bananas");
+
+ static async Task AssertViewModelProperty(AutoSuggestBox autoSuggestBox)
+ {
+ var viewModel = (AutoSuggestTextBoxWithCollectionViewViewModel)autoSuggestBox.DataContext;
+ await Assert.That(viewModel.SelectedItem).IsEqualTo("Bananas");
+ }
+ await suggestBox.RemoteExecute(AssertViewModelProperty);
+
+ recorder.Success();
}
private static async Task AssertExists(IVisualElement suggestionListBox, string text, bool existsOrNotCheck = true)
@@ -206,11 +237,11 @@ private static async Task AssertExists(IVisualElement suggestionListBox
try
{
_ = await suggestionListBox.GetElement(ElementQuery.PropertyExpression(x => x.Text, text));
- Assert.True(existsOrNotCheck);
+ await Assert.That(existsOrNotCheck).IsTrue();
}
- catch (Exception e) when (e is not TrueException)
+ catch (Exception e) when (e is not TUnitException)
{
- Assert.False(existsOrNotCheck);
+ await Assert.That(existsOrNotCheck).IsFalse();
}
}
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/Buttons/OutlineButtonTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Buttons/OutlineButtonTests.cs
index 1718fcc834..312ab51d28 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/Buttons/OutlineButtonTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/Buttons/OutlineButtonTests.cs
@@ -4,11 +4,7 @@ namespace MaterialDesignThemes.UITests.WPF.Buttons;
public class OutlineButtonTests : TestBase
{
- public OutlineButtonTests(ITestOutputHelper output)
- : base(output)
- { }
-
- [Fact]
+ [Test]
public async Task OutlinedButton_UsesThemeColorForBorder()
{
await using var recorder = new TestRecorder(App);
@@ -24,13 +20,13 @@ public async Task OutlinedButton_UsesThemeColorForBorder()
Color? internalBorderColor = await internalBorder.GetBorderBrushColor();
//Assert
- Assert.Equal(midColor, borderColor);
- Assert.Equal(midColor, internalBorderColor);
+ await Assert.That(borderColor).IsEqualTo(midColor);
+ await Assert.That(internalBorderColor).IsEqualTo(midColor);
recorder.Success();
}
- [Fact]
+ [Test]
public async Task OutlinedButton_BorderCanBeOverridden()
{
await using var recorder = new TestRecorder(App);
@@ -50,13 +46,13 @@ public async Task OutlinedButton_BorderCanBeOverridden()
Color? borderBrush = await internalBorder.GetBorderBrushColor();
//Assert
- Assert.Equal(new Thickness(5), borderThickness);
- Assert.Equal(Colors.Red, borderBrush);
+ await Assert.That(borderThickness).IsEqualTo(new Thickness(5));
+ await Assert.That(borderBrush).IsEqualTo(Colors.Red);
recorder.Success();
}
- [Fact]
+ [Test]
public async Task OutlinedButton_OnMouseOver_UsesThemeBrush()
{
await using var recorder = new TestRecorder(App);
@@ -74,7 +70,7 @@ await Wait.For(async () =>
SolidColorBrush? internalBorderBackground = (await internalBorder.GetBackground()) as SolidColorBrush;
//Assert
- Assert.Equal(midColor, internalBorderBackground?.Color);
+ await Assert.That(internalBorderBackground?.Color).IsEqualTo(midColor);
});
recorder.Success();
diff --git a/tests/MaterialDesignThemes.UITests/WPF/Buttons/RaisedButtonTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Buttons/RaisedButtonTests.cs
index c0ed522aec..39c7b3ea7a 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/Buttons/RaisedButtonTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/Buttons/RaisedButtonTests.cs
@@ -4,11 +4,7 @@ namespace MaterialDesignThemes.UITests.WPF.Buttons;
public class RaisedButtonTests : TestBase
{
- public RaisedButtonTests(ITestOutputHelper output)
- : base(output)
- { }
-
- [Fact]
+ [Test]
public async Task OnLoad_ThemeBrushesSet()
{
await using var recorder = new TestRecorder(App);
@@ -21,7 +17,7 @@ public async Task OnLoad_ThemeBrushesSet()
Color? color = await button.GetBackgroundColor();
//Assert
- Assert.Equal(midColor, color);
+ await Assert.That(color).IsEqualTo(midColor);
recorder.Success();
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/Cards/ElevatedCardTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Cards/ElevatedCardTests.cs
index f30f158a9e..1187395aee 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/Cards/ElevatedCardTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/Cards/ElevatedCardTests.cs
@@ -1,12 +1,11 @@
-namespace MaterialDesignThemes.UITests.WPF.Cards;
+
+
+namespace MaterialDesignThemes.UITests.WPF.Cards;
public class ElevatedCardTests : TestBase
{
- public ElevatedCardTests(ITestOutputHelper output)
- : base(output)
- { }
- [Fact]
+ [Test]
public async Task ElevatedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnBorder()
{
await using var recorder = new TestRecorder(App);
@@ -20,10 +19,10 @@ public async Task ElevatedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnB
CornerRadius? internalBorderCornerRadius = await internalBorder.GetCornerRadius();
//Assert
- Assert.Equal(5, internalBorderCornerRadius.Value.TopLeft);
- Assert.Equal(5, internalBorderCornerRadius.Value.TopRight);
- Assert.Equal(5, internalBorderCornerRadius.Value.BottomRight);
- Assert.Equal(5, internalBorderCornerRadius.Value.BottomLeft);
+ await Assert.That(internalBorderCornerRadius.Value.TopLeft).IsEqualTo(5);
+ await Assert.That(internalBorderCornerRadius.Value.TopRight).IsEqualTo(5);
+ await Assert.That(internalBorderCornerRadius.Value.BottomRight).IsEqualTo(5);
+ await Assert.That(internalBorderCornerRadius.Value.BottomLeft).IsEqualTo(5);
recorder.Success();
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs b/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs
index 424cbaf138..15da509acc 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/Cards/OutlinedCardTests.cs
@@ -4,11 +4,7 @@ namespace MaterialDesignThemes.UITests.WPF.Cards;
public class OutlinedCardTests : TestBase
{
- public OutlinedCardTests(ITestOutputHelper output)
- : base(output)
- { }
-
- [Fact]
+ [Test]
public async Task OutlinedCard_UsesThemeColorForBorder()
{
await using var recorder = new TestRecorder(App);
@@ -23,12 +19,12 @@ public async Task OutlinedCard_UsesThemeColorForBorder()
Color? internalBorderColor = await internalBorder.GetBorderBrushColor();
//Assert
- Assert.Equal(dividerColor, internalBorderColor);
+ await Assert.That(internalBorderColor).IsEqualTo(dividerColor);
recorder.Success();
}
- [Fact]
+ [Test]
public async Task OutlinedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnBorder()
{
await using var recorder = new TestRecorder(App);
@@ -42,10 +38,10 @@ public async Task OutlinedCard_UniformCornerRadiusApplied_AppliesCornerRadiusOnB
CornerRadius? internalBorderCornerRadius = await internalBorder.GetCornerRadius();
//Assert
- Assert.Equal(5, internalBorderCornerRadius.Value.TopLeft);
- Assert.Equal(5, internalBorderCornerRadius.Value.TopRight);
- Assert.Equal(5, internalBorderCornerRadius.Value.BottomRight);
- Assert.Equal(5, internalBorderCornerRadius.Value.BottomLeft);
+ await Assert.That(internalBorderCornerRadius.Value.TopLeft).IsEqualTo(5);
+ await Assert.That(internalBorderCornerRadius.Value.TopRight).IsEqualTo(5);
+ await Assert.That(internalBorderCornerRadius.Value.BottomRight).IsEqualTo(5);
+ await Assert.That(internalBorderCornerRadius.Value.BottomLeft).IsEqualTo(5);
recorder.Success();
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs
index 57805e8a1c..922a0b5cd8 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/ColorPickerTests.cs
@@ -5,12 +5,7 @@ namespace MaterialDesignThemes.UITests.WPF;
public class ColorPickerTests : TestBase
{
- public ColorPickerTests(ITestOutputHelper output)
- : base(output)
- {
- }
-
- [Fact]
+ [Test]
public async Task OnLostFocusIfSelectedTimeIsNull_DatePartWillBeToday()
{
await using var recorder = new TestRecorder(App);
@@ -29,12 +24,12 @@ public async Task OnLostFocusIfSelectedTimeIsNull_DatePartWillBeToday()
await thumb.SendInput(MouseInput.MoveRelative(xOffset: -5, yOffset: -10));
await thumb.SendInput(MouseInput.LeftDown());
await thumb.SendInput(MouseInput.MoveRelative(yOffset: 25));
- await Task.Delay(100);
+ await Task.Delay(100, TestContext.Current!.CancellationToken);
await thumb.SendInput(MouseInput.LeftUp());
double currentBrightness = (await colorPicker.GetColor()).ToHsb().Brightness;
- Assert.True(currentBrightness < lastBrightness, $"Brightness {currentBrightness} is not less than {lastBrightness}");
+ await Assert.That(currentBrightness).IsLessThan(lastBrightness);
recorder.Success();
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/ColorZones/ColorZoneTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ColorZones/ColorZoneTests.cs
index 6422947496..bc8dca69ca 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/ColorZones/ColorZoneTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/ColorZones/ColorZoneTests.cs
@@ -1,26 +1,21 @@
using System.Windows.Media;
+
namespace MaterialDesignThemes.UITests.WPF.ColorZones;
public class ColorZoneTests : TestBase
{
- public ColorZoneTests(ITestOutputHelper output)
- : base(output)
- {
-
- }
-
- [Theory]
- [InlineData(ColorZoneMode.Standard, "MaterialDesign.Brush.Background", "MaterialDesign.Brush.Foreground")]
- [InlineData(ColorZoneMode.Inverted, "MaterialDesign.Brush.Foreground", "MaterialDesign.Brush.Background")]
- [InlineData(ColorZoneMode.PrimaryLight, "MaterialDesign.Brush.Primary.Light", "MaterialDesign.Brush.Primary.Light.Foreground")]
- [InlineData(ColorZoneMode.PrimaryMid, "MaterialDesign.Brush.Primary", "MaterialDesign.Brush.Primary.Foreground")]
- [InlineData(ColorZoneMode.PrimaryDark, "MaterialDesign.Brush.Primary.Dark", "MaterialDesign.Brush.Primary.Dark.Foreground")]
- [InlineData(ColorZoneMode.SecondaryLight, "MaterialDesign.Brush.Secondary.Light", "MaterialDesign.Brush.Secondary.Light.Foreground")]
- [InlineData(ColorZoneMode.SecondaryMid, "MaterialDesign.Brush.Secondary", "MaterialDesign.Brush.Secondary.Foreground")]
- [InlineData(ColorZoneMode.SecondaryDark, "MaterialDesign.Brush.Secondary.Dark", "MaterialDesign.Brush.Secondary.Dark.Foreground")]
- [InlineData(ColorZoneMode.Light, "MaterialDesign.Brush.ColorZone.LightBackground", "MaterialDesign.Brush.ColorZone.LightForeground")]
- [InlineData(ColorZoneMode.Dark, "MaterialDesign.Brush.ColorZone.DarkBackground", "MaterialDesign.Brush.ColorZone.DarkForeground")]
+ [Test]
+ [Arguments(ColorZoneMode.Standard, "MaterialDesign.Brush.Background", "MaterialDesign.Brush.Foreground")]
+ [Arguments(ColorZoneMode.Inverted, "MaterialDesign.Brush.Foreground", "MaterialDesign.Brush.Background")]
+ [Arguments(ColorZoneMode.PrimaryLight, "MaterialDesign.Brush.Primary.Light", "MaterialDesign.Brush.Primary.Light.Foreground")]
+ [Arguments(ColorZoneMode.PrimaryMid, "MaterialDesign.Brush.Primary", "MaterialDesign.Brush.Primary.Foreground")]
+ [Arguments(ColorZoneMode.PrimaryDark, "MaterialDesign.Brush.Primary.Dark", "MaterialDesign.Brush.Primary.Dark.Foreground")]
+ [Arguments(ColorZoneMode.SecondaryLight, "MaterialDesign.Brush.Secondary.Light", "MaterialDesign.Brush.Secondary.Light.Foreground")]
+ [Arguments(ColorZoneMode.SecondaryMid, "MaterialDesign.Brush.Secondary", "MaterialDesign.Brush.Secondary.Foreground")]
+ [Arguments(ColorZoneMode.SecondaryDark, "MaterialDesign.Brush.Secondary.Dark", "MaterialDesign.Brush.Secondary.Dark.Foreground")]
+ [Arguments(ColorZoneMode.Light, "MaterialDesign.Brush.ColorZone.LightBackground", "MaterialDesign.Brush.ColorZone.LightForeground")]
+ [Arguments(ColorZoneMode.Dark, "MaterialDesign.Brush.ColorZone.DarkBackground", "MaterialDesign.Brush.ColorZone.DarkForeground")]
public async Task Mode_SetsThemeColors(ColorZoneMode mode, string backgroundBrush, string foregroundBrush)
{
await using var recorder = new TestRecorder(App);
@@ -31,8 +26,8 @@ public async Task Mode_SetsThemeColors(ColorZoneMode mode, string backgroundBrus
Color background = await GetThemeColor(backgroundBrush);
Color foreground = await GetThemeColor(foregroundBrush);
- Assert.Equal(background, await colorZone.GetBackgroundColor());
- Assert.Equal(foreground, await colorZone.GetForegroundColor());
+ await Assert.That(await colorZone.GetBackgroundColor()).IsEqualTo(background);
+ await Assert.That(await colorZone.GetForegroundColor()).IsEqualTo(foreground);
recorder.Success();
}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs
index d081596312..1510cf2b05 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs
@@ -5,12 +5,7 @@ namespace MaterialDesignThemes.UITests.WPF.ComboBoxes;
public class ComboBoxTests : TestBase
{
- public ComboBoxTests(ITestOutputHelper output)
- : base(output)
- {
- }
-
- [Fact]
+ [Test]
[Description("Pull Request 2192")]
public async Task OnComboBoxHelperTextFontSize_ChangesHelperTextFontSize()
{
@@ -26,11 +21,11 @@ public async Task OnComboBoxHelperTextFontSize_ChangesHelperTextFontSize()
double fontSize = await helpTextBlock.GetFontSize();
- Assert.Equal(20, fontSize);
+ await Assert.That(fontSize).IsEqualTo(20);
recorder.Success();
}
- [Fact]
+ [Test]
[Description("Pull Request 2192")]
public async Task OnFilledComboBoxHelperTextFontSize_ChangesHelperTextFontSize()
{
@@ -47,11 +42,11 @@ public async Task OnFilledComboBoxHelperTextFontSize_ChangesHelperTextFontSize()
double fontSize = await helpTextBlock.GetFontSize();
- Assert.Equal(20, fontSize);
+ await Assert.That(fontSize).IsEqualTo(20);
recorder.Success();
}
- [Fact]
+ [Test]
[Description("Issue 2495")]
public async Task OnComboBox_WithClearButton_ClearsSelection()
{
@@ -74,23 +69,23 @@ public async Task OnComboBox_WithClearButton_ClearsSelection()
int? selectedIndex = await comboBox.GetSelectedIndex();
object? text = await comboBox.GetText();
- Assert.True(selectedIndex >= 0);
- Assert.NotNull(text);
+ await Assert.That(selectedIndex >= 0).IsTrue();
+ await Assert.That(text).IsNotNull();
await clearButton.LeftClick();
await Wait.For(async () =>
{
text = await comboBox.GetText();
- Assert.Null(text);
+ await Assert.That(text).IsNull();
selectedIndex = await comboBox.GetSelectedIndex();
- Assert.False(selectedIndex >= 0);
+ await Assert.That(selectedIndex >= 0).IsFalse();
});
recorder.Success();
}
- [Fact]
+ [Test]
[Description("Issue 2690")]
public async Task OnEditableComboBox_WithDefaultContextMenu_ShowsCutCopyPaste()
{
@@ -108,7 +103,7 @@ public async Task OnEditableComboBox_WithDefaultContextMenu_ShowsCutCopyPaste()
await comboBox.RightClick();
IVisualElement? contextMenu = await comboBox.GetContextMenu();
- Assert.True(contextMenu is not null, "No context menu set on the ComboBox");
+ await Assert.That(contextMenu).IsNotNull().Because("No context menu set on the ComboBox");
await Wait.For(async () => await contextMenu!.GetIsVisible());
await AssertMenu("Cut");
await AssertMenu("Copy");
@@ -119,11 +114,11 @@ public async Task OnEditableComboBox_WithDefaultContextMenu_ShowsCutCopyPaste()
async Task AssertMenu(string menuHeader)
{
var menuItem = await contextMenu!.GetElement(ElementQuery.PropertyExpression