Skip to content

Commit

Permalink
Fix winui3 cursor bug(microsoft/microsoft-ui-xaml#7062)
Browse files Browse the repository at this point in the history
Fix winui3 cursor bug(microsoft/microsoft-ui-xaml#7062)
  • Loading branch information
Gaoyifei1011 committed Sep 9, 2023
1 parent d2d5ae7 commit df5dbc4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 18 deletions.
1 change: 0 additions & 1 deletion GetStoreApp/GetStoreApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<TargetPlatformMinVersion>10.0.19044.0</TargetPlatformMinVersion>
<TrimMode>partial</TrimMode>
<TrimmerRemoveSymbols>true</TrimmerRemoveSymbols>
<UseWinUI>true</UseWinUI>
<WindowsAppSDKDeploymentManagerInitialize>false</WindowsAppSDKDeploymentManagerInitialize>
<WindowsAppSDKSelfContained>false</WindowsAppSDKSelfContained>
<WindowsPackageType>MSIX</WindowsPackageType>
Expand Down
15 changes: 4 additions & 11 deletions GetStoreApp/Helpers/Controls/Extensions/CursorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,13 @@ public static InputSystemCursorShape GetCursor(DependencyObject obj)
public static void SetCursor(DependencyObject obj, InputSystemCursorShape value)
{
obj.SetValue(CursorProperty, value);
}

public static readonly DependencyProperty CursorProperty =
DependencyProperty.RegisterAttached("Cursor", typeof(InputSystemCursorShape), typeof(CursorHelper), new PropertyMetadata(InputSystemCursorShape.Arrow, OnCursorChanged));

public static void OnCursorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
{
if (obj is FrameworkElement element)
{
element.Loaded += (sender, args) =>
{
typeof(FrameworkElement).GetProperty("ProtectedCursor", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(element, InputSystemCursor.Create(GetCursor(sender as FrameworkElement)));
};
typeof(FrameworkElement).GetProperty("ProtectedCursor", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(element, InputSystemCursor.Create(GetCursor(element)));
}
}

public static readonly DependencyProperty CursorProperty =
DependencyProperty.RegisterAttached("Cursor", typeof(InputSystemCursorShape), typeof(CursorHelper), new PropertyMetadata(InputSystemCursorShape.Arrow));
}
}
6 changes: 3 additions & 3 deletions GetStoreApp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// 程序集信息设置
[assembly: AssemblyCopyright("Copyright ©2022-2023 高怡飞, All Rights Reserved.")]
[assembly: AssemblyDescription("获取商店应用")]
[assembly: AssemblyFileVersion("2.3.906.0")]
[assembly: AssemblyInformationalVersion("2.3.906.0")]
[assembly: AssemblyFileVersion("2.3.909.0")]
[assembly: AssemblyInformationalVersion("2.3.909.0")]
[assembly: AssemblyProduct("获取商店应用")]
[assembly: AssemblyTitle("获取商店应用")]
[assembly: AssemblyVersion("2.3.906.0")]
[assembly: AssemblyVersion("2.3.909.0")]

// 设置程序集对COM组件的访问权限
[assembly: ComVisible(false)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using GetStoreApp.WindowsAPI.ComTypes;
using System;
using Windows.ApplicationModel.DataTransfer;
using WinRT;

namespace GetStoreApp.WindowsAPI.Controls
{
Expand All @@ -19,7 +18,7 @@ public static class DataTransferManagerInterop
/// </summary>
public static DataTransferManager GetForWindow(IntPtr window)
{
return MarshalInterface<DataTransferManager>.FromAbi(dataTransferManagerInterop.GetForWindow(window, riid));
return DataTransferManager.FromAbi(dataTransferManagerInterop.GetForWindow(window, riid));
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion GetStoreAppPackage/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Identity
Name="Gaoyifei1011.GetStoreApp"
Publisher="CN=高怡飞"
Version="2.3.906.0" />
Version="2.3.909.0" />

<Properties>
<DisplayName>ms-resource:PackageDisplayName</DisplayName>
Expand Down

0 comments on commit df5dbc4

Please sign in to comment.