diff --git a/scripts/Microsoft.Xaml.Behaviors.WinUI.Managed.nuspec b/scripts/Microsoft.Xaml.Behaviors.WinUI.Managed.nuspec
index 0f256998..5adfd1f8 100644
--- a/scripts/Microsoft.Xaml.Behaviors.WinUI.Managed.nuspec
+++ b/scripts/Microsoft.Xaml.Behaviors.WinUI.Managed.nuspec
@@ -14,33 +14,33 @@
© Microsoft Corporation. All rights reserved.
Behavior Action Behaviors Actions Blend Managed C# Interaction Interactivity Interactions WinUI
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Design/Microsoft.Xaml.Interactions.Design.csproj b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Design/Microsoft.Xaml.Interactions.Design.csproj
index 2d5e0852..eab3d68d 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Design/Microsoft.Xaml.Interactions.Design.csproj
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Design/Microsoft.Xaml.Interactions.Design.csproj
@@ -1,6 +1,6 @@
-
+
Debug
@@ -131,10 +131,10 @@
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-
+
+
+
-
-
+
+
\ No newline at end of file
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Design/packages.config b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Design/packages.config
index 0706e41e..c9d436c0 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Design/packages.config
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Design/packages.config
@@ -1,5 +1,5 @@
-
-
+
+
\ No newline at end of file
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.DesignTools/Microsoft.Xaml.Interactions.DesignTools.csproj b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.DesignTools/Microsoft.Xaml.Interactions.DesignTools.csproj
index 1f9b424f..a186cbff 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.DesignTools/Microsoft.Xaml.Interactions.DesignTools.csproj
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.DesignTools/Microsoft.Xaml.Interactions.DesignTools.csproj
@@ -101,12 +101,12 @@
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
+
+
- 0.4.1
+ 1.0.0
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/CallMethodAction.cs b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/CallMethodAction.cs
index 73d0dbea..37ec79a8 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/CallMethodAction.cs
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/CallMethodAction.cs
@@ -21,6 +21,9 @@ namespace Microsoft.Xaml.Interactions.Core
///
/// An action that calls a method on a specified object when invoked.
///
+#if NET8_0_OR_GREATER
+ [RequiresUnreferencedCode("This action is not trim-safe.")]
+#endif
public sealed class CallMethodAction : DependencyObject, IAction
{
///
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/ChangePropertyAction.cs b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/ChangePropertyAction.cs
index ec8ae226..a0e63b4c 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/ChangePropertyAction.cs
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/ChangePropertyAction.cs
@@ -19,6 +19,9 @@ namespace Microsoft.Xaml.Interactions.Core
///
/// An action that will change a specified property to a specified value when invoked.
///
+#if NET8_0_OR_GREATER
+ [RequiresUnreferencedCode("This action is not trim-safe.")]
+#endif
public sealed class ChangePropertyAction : DependencyObject, IAction
{
///
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/DataBindingHelper.cs b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/DataBindingHelper.cs
index db0550af..a1c3680c 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/DataBindingHelper.cs
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/DataBindingHelper.cs
@@ -3,6 +3,9 @@
using System;
using System.Collections.Generic;
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
using System.Reflection;
using Microsoft.Xaml.Interactivity;
@@ -29,6 +32,9 @@ internal static class DataBindingHelper
/// bindings on the action may not be up-to-date. This routine is called before the action
/// is executed in order to guarantee that all bindings are refreshed with the most current data.
///
+#if NET8_0_OR_GREATER
+ [RequiresUnreferencedCode("This method accesses all fields of input action objects.")]
+#endif
public static void RefreshDataBindingsOnActions(ActionCollection actions)
{
foreach (DependencyObject action in actions)
@@ -40,7 +46,11 @@ public static void RefreshDataBindingsOnActions(ActionCollection actions)
}
}
- private static IEnumerable GetDependencyProperties(Type type)
+ private static IEnumerable GetDependencyProperties(
+#if NET8_0_OR_GREATER
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
+#endif
+ Type type)
{
List propertyList = null;
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/DataTriggerBehavior.cs b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/DataTriggerBehavior.cs
index 4b9f7dc8..57fda588 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/DataTriggerBehavior.cs
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/DataTriggerBehavior.cs
@@ -18,6 +18,9 @@ namespace Microsoft.Xaml.Interactions.Core
///
/// A behavior that performs actions when the bound data meets a specified condition.
///
+#if NET8_0_OR_GREATER
+ [RequiresUnreferencedCode("This behavior is not trim-safe.")]
+#endif
public sealed class DataTriggerBehavior : Trigger
{
///
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/EventTriggerBehavior.cs b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/EventTriggerBehavior.cs
index 64168050..6b3591ec 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/EventTriggerBehavior.cs
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/EventTriggerBehavior.cs
@@ -21,6 +21,9 @@ namespace Microsoft.Xaml.Interactions.Core
///
/// A behavior that listens for a specified event on its source and executes its actions when that event is fired.
///
+#if NET8_0_OR_GREATER
+ [RequiresUnreferencedCode("This behavior is not trim-safe.")]
+#endif
public sealed class EventTriggerBehavior : Trigger
{
///
@@ -181,7 +184,7 @@ private void RegisterEvent(string eventName)
else if (!this._isLoadedEventRegistered)
{
FrameworkElement element = this._resolvedSource as FrameworkElement;
- if (element != null && !EventTriggerBehavior.IsElementLoaded(element))
+ if (element != null && !EventTriggerBehaviorHelpers.IsElementLoaded(element))
{
this._isLoadedEventRegistered = true;
element.Loaded += this.OnEvent;
@@ -253,7 +256,33 @@ private static void OnEventNameChanged(DependencyObject dependencyObject, Depend
behavior.RegisterEvent(newEventName);
}
- internal static bool IsElementLoaded(FrameworkElement element)
+#if !WinUI
+ private static bool IsWindowsRuntimeEvent(EventInfo eventInfo)
+ {
+ return eventInfo != null &&
+ EventTriggerBehavior.IsWindowsRuntimeType(eventInfo.EventHandlerType) &&
+ EventTriggerBehavior.IsWindowsRuntimeType(eventInfo.DeclaringType);
+ }
+
+ private static bool IsWindowsRuntimeType(Type type)
+ {
+ if (type != null)
+ {
+ // This will only work when using built-in WinRT interop, ie. where .winmd files are directly
+ // referenced instead of generated projections. That is, this would not work on modern .NET.
+ return type.AssemblyQualifiedName.EndsWith("ContentType=WindowsRuntime", StringComparison.Ordinal);
+ }
+
+ return false;
+ }
+#endif
+ }
+
+ internal static class EventTriggerBehaviorHelpers
+ {
+ // This method has to be outside of 'EventTriggerBehavior', because it's actually trim-safe.
+ // We want to allow other callers inside the library use this without getting trim warnings.
+ public static bool IsElementLoaded(FrameworkElement element)
{
if (element == null)
{
@@ -280,22 +309,5 @@ internal static bool IsElementLoaded(FrameworkElement element)
return (parent != null || (rootVisual != null && element == rootVisual));
}
-
- private static bool IsWindowsRuntimeEvent(EventInfo eventInfo)
- {
- return eventInfo != null &&
- EventTriggerBehavior.IsWindowsRuntimeType(eventInfo.EventHandlerType) &&
- EventTriggerBehavior.IsWindowsRuntimeType(eventInfo.DeclaringType);
- }
-
- private static bool IsWindowsRuntimeType(Type type)
- {
- if (type != null)
- {
- return type.AssemblyQualifiedName.EndsWith("ContentType=WindowsRuntime", StringComparison.Ordinal);
- }
-
- return false;
- }
}
}
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/GoToStateAction.cs b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/GoToStateAction.cs
index 31249565..7e99f18c 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/GoToStateAction.cs
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/GoToStateAction.cs
@@ -127,7 +127,7 @@ public object Execute(object sender, object parameter)
}
FrameworkElement element = sender as FrameworkElement;
- if (element == null || !EventTriggerBehavior.IsElementLoaded(element))
+ if (element == null || !EventTriggerBehaviorHelpers.IsElementLoaded(element))
{
return false;
}
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/ResourceHelper.cs b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/ResourceHelper.cs
index 73ad44f0..7884c6f3 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/ResourceHelper.cs
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/ResourceHelper.cs
@@ -7,13 +7,13 @@ namespace Microsoft.Xaml.Interactions.Core
internal static class ResourceHelper
{
-#if NET5_0
+#if NET8_0_OR_GREATER
private static ResourceLoader strings = new ResourceLoader(ResourceLoader.GetDefaultResourceFilePath(), "Microsoft.Xaml.Interactions/Strings");
#endif
public static string GetString(string resourceName)
{
-#if !NET5_0
+#if !NET8_0_OR_GREATER
var strings = ResourceLoader.GetForCurrentView("Microsoft.Xaml.Interactions/Strings");
#endif
return strings.GetString(resourceName);
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.WinUI/Microsoft.Xaml.Interactions.WinUI.csproj b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.WinUI/Microsoft.Xaml.Interactions.WinUI.csproj
index 345cd4e3..694e9f9c 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.WinUI/Microsoft.Xaml.Interactions.WinUI.csproj
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.WinUI/Microsoft.Xaml.Interactions.WinUI.csproj
@@ -1,13 +1,15 @@
Library
- net5.0-windows10.0.17763.0
+ net8.0-windows10.0.17763.0
10.0.17763.0
Microsoft.Xaml.Interactions
- AnyCPU;x86;x64
+ AnyCPU;x86;x64;arm64
+ win-x86;win-x64;win-arm64
10.0.17763.0
$(TargetPlatformMinVersion)
false
+ true
AnyCPU
@@ -118,11 +120,11 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Microsoft.Xaml.Interactions.csproj b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Microsoft.Xaml.Interactions.csproj
index 513cdbd9..d4ee71f9 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Microsoft.Xaml.Interactions.csproj
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Microsoft.Xaml.Interactions.csproj
@@ -157,7 +157,9 @@
6.2.10
- 0.4.1
+ 1.0.0
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
diff --git a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactivity.Design/Microsoft.Xaml.Interactivity.Design.csproj b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactivity.Design/Microsoft.Xaml.Interactivity.Design.csproj
index e311f3a1..149ad4a1 100644
--- a/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactivity.Design/Microsoft.Xaml.Interactivity.Design.csproj
+++ b/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactivity.Design/Microsoft.Xaml.Interactivity.Design.csproj
@@ -1,6 +1,6 @@
-
+
Debug
@@ -117,10 +117,10 @@
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
+
+
-
+