diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1d6e32e0..3b0db68e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ on: merge_group: env: - DOTNET_VERSION: ${{ '9.0.100' }} + DOTNET_VERSION: ${{ '9.0.x' }} ENABLE_DIAGNOSTICS: true MSBUILD_VERBOSITY: normal #COREHOST_TRACE: 1 diff --git a/Directory.Build.props b/Directory.Build.props index fd024110..887804ab 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -27,6 +27,9 @@ $(NoWarn);Uno0001 $(NoWarn);TKSMPL0014; + + + NU1901;NU1902;NU1903;NU1904 diff --git a/GenerateAllSolution.bat b/GenerateAllSolution.bat index c4344e07..61551e18 100644 --- a/GenerateAllSolution.bat +++ b/GenerateAllSolution.bat @@ -1,5 +1,5 @@ @ECHO OFF SET "MultiTargets=%1" -IF "%MultiTargets%"=="" SET "MultiTargets=all" +IF "%MultiTargets%"=="" SET "MultiTargets=uwp,wasdk,wasm" powershell .\tooling\GenerateAllSolution.ps1 -MultiTargets %MultiTargets% \ No newline at end of file diff --git a/components/Behaviors/samples/InvokeActionsSample.xaml b/components/Behaviors/samples/InvokeActionsSample.xaml index 47f1e748..f85645fa 100644 --- a/components/Behaviors/samples/InvokeActionsSample.xaml +++ b/components/Behaviors/samples/InvokeActionsSample.xaml @@ -5,7 +5,6 @@ xmlns:ani="using:CommunityToolkit.WinUI.Animations" xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:interactions="using:Microsoft.Xaml.Interactions.Core" xmlns:interactivity="using:Microsoft.Xaml.Interactivity" xmlns:local="using:BehaviorsExperiment.Samples" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -20,7 +19,7 @@ IsSequential="True"> - @@ -53,12 +52,12 @@ - - + - + diff --git a/components/Behaviors/samples/KeyDownTriggerBehaviorSample.xaml b/components/Behaviors/samples/KeyDownTriggerBehaviorSample.xaml index 9594ef02..4938c2dc 100644 --- a/components/Behaviors/samples/KeyDownTriggerBehaviorSample.xaml +++ b/components/Behaviors/samples/KeyDownTriggerBehaviorSample.xaml @@ -2,7 +2,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors" - xmlns:core="using:Microsoft.Xaml.Interactions.Core" xmlns:interactivity="using:Microsoft.Xaml.Interactivity"> - diff --git a/components/Behaviors/samples/NavigateToUriActionSample.xaml b/components/Behaviors/samples/NavigateToUriActionSample.xaml index 980a9d94..e6a3dd7c 100644 --- a/components/Behaviors/samples/NavigateToUriActionSample.xaml +++ b/components/Behaviors/samples/NavigateToUriActionSample.xaml @@ -2,14 +2,13 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors" - xmlns:core="using:Microsoft.Xaml.Interactions.Core" xmlns:interactivity="using:Microsoft.Xaml.Interactivity"> diff --git a/components/Behaviors/samples/StartAnimationActivitySample.xaml b/components/Behaviors/samples/StartAnimationActivitySample.xaml index cc850756..a349727f 100644 --- a/components/Behaviors/samples/StartAnimationActivitySample.xaml +++ b/components/Behaviors/samples/StartAnimationActivitySample.xaml @@ -5,7 +5,6 @@ xmlns:ani="using:CommunityToolkit.WinUI.Animations" xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:interactions="using:Microsoft.Xaml.Interactions.Core" xmlns:interactivity="using:Microsoft.Xaml.Interactivity" xmlns:local="using:BehaviorsExperiment.Samples" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -55,9 +54,9 @@ - + - + diff --git a/components/Behaviors/src/Dependencies.props b/components/Behaviors/src/Dependencies.props index aec754a1..c6da10ee 100644 --- a/components/Behaviors/src/Dependencies.props +++ b/components/Behaviors/src/Dependencies.props @@ -11,21 +11,21 @@ - + - + - + - + diff --git a/components/Converters/src/ColorToDisplayNameConverter.cs b/components/Converters/src/ColorToDisplayNameConverter.cs index 6a22ff67..3aeecc81 100644 --- a/components/Converters/src/ColorToDisplayNameConverter.cs +++ b/components/Converters/src/ColorToDisplayNameConverter.cs @@ -38,7 +38,12 @@ public object Convert( // Track https://github.com/unoplatform/uno/issues/18004 return "Not supported"; #elif WINUI2 +#if NET8_0_OR_GREATER + // Following advice from Sergio0694 + return color.ToString(); +#else return Windows.UI.ColorHelper.ToDisplayName(color); +#endif #elif WINUI3 return Microsoft.UI.ColorHelper.ToDisplayName(color); #endif diff --git a/components/Converters/src/ResourceNameToResourceStringConverter.cs b/components/Converters/src/ResourceNameToResourceStringConverter.cs index ab9bf03b..e97a6bcc 100644 --- a/components/Converters/src/ResourceNameToResourceStringConverter.cs +++ b/components/Converters/src/ResourceNameToResourceStringConverter.cs @@ -32,18 +32,18 @@ public sealed partial class ResourceNameToResourceStringConverter : IValueConver /// Optional parameter. Not used. /// The language of the conversion. /// The string corresponding to the resource name. - public object Convert(object value, Type targetType, object parameter, string language) + public object? Convert(object value, Type targetType, object parameter, string language) { - var stringValue = value?.ToString(); - if (stringValue is null) + var valueAsString = value?.ToString(); + if (valueAsString == null) { return string.Empty; } #if WINAPPSDK && !HAS_UNO - return _resourceManager.MainResourceMap.TryGetValue(stringValue).ValueAsString; + return _resourceManager.MainResourceMap.TryGetValue(valueAsString).ValueAsString; #else - return _resourceLoader.GetString(stringValue) ?? string.Empty; + return _resourceLoader.GetString(valueAsString) ?? string.Empty; #endif } diff --git a/components/Extensions/samples/Dispatcher/KeyboardDebounceSample.xaml b/components/Extensions/samples/Dispatcher/KeyboardDebounceSample.xaml new file mode 100644 index 00000000..3de79e5e --- /dev/null +++ b/components/Extensions/samples/Dispatcher/KeyboardDebounceSample.xaml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/components/Extensions/samples/Dispatcher/KeyboardDebounceSample.xaml.cs b/components/Extensions/samples/Dispatcher/KeyboardDebounceSample.xaml.cs new file mode 100644 index 00000000..e3ce6ee2 --- /dev/null +++ b/components/Extensions/samples/Dispatcher/KeyboardDebounceSample.xaml.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using CommunityToolkit.WinUI; +#if WINAPPSDK +using DispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue; +using DispatcherQueueTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer; +#else +using DispatcherQueue = Windows.System.DispatcherQueue; +using DispatcherQueueTimer = Windows.System.DispatcherQueueTimer; +#endif + +namespace ExtensionsExperiment.Samples.DispatcherQueueExtensions; + +[ToolkitSample(id: nameof(KeyboardDebounceSample), "DispatcherQueueTimer Debounce Keyboard", description: "A sample for showing how to use the DispatcherQueueTimer Debounce extension to smooth keyboard input.")] +[ToolkitSampleNumericOption("Interval", 120, 60, 240)] +public sealed partial class KeyboardDebounceSample : Page +{ + public DispatcherQueueTimer _debounceTimer = DispatcherQueue.GetForCurrentThread().CreateTimer(); + + public KeyboardDebounceSample() + { + InitializeComponent(); + } + + private void TextBox_TextChanged(object sender, TextChangedEventArgs e) + { + if (sender is TextBox textBox) + { + _debounceTimer.Debounce(() => + { + ResultText.Text = textBox.Text; + }, + //// i.e. if another keyboard press comes in within 120ms of the last, we'll wait before we fire off the request + interval: TimeSpan.FromMilliseconds(Interval), + //// If we're blanking out or the first character type, we'll start filtering immediately instead to appear more responsive. + //// We want to switch back to trailing as the user types more so that we still capture all the input. + immediate: textBox.Text.Length <= 1); + } + } +} diff --git a/components/Extensions/samples/Dispatcher/MouseDebounceSample.xaml b/components/Extensions/samples/Dispatcher/MouseDebounceSample.xaml new file mode 100644 index 00000000..d44d17f7 --- /dev/null +++ b/components/Extensions/samples/Dispatcher/MouseDebounceSample.xaml @@ -0,0 +1,14 @@ + + + +