是否可以更改甚至隱藏UWP應用程序中的鼠標指針?我只能找到這個:更改UWP應用程序中的鼠標指針
Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = null;
但在UWP中,這是行不通的。
是否可以更改甚至隱藏UWP應用程序中的鼠標指針?我只能找到這個:更改UWP應用程序中的鼠標指針
Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = null;
但在UWP中,這是行不通的。
是的,這可以通過設置 Window.Current.CoreWindow.PointerCursor
來完成。如果您將其設置爲空,指針將被隱藏。否則,您可以使用枚舉CoreCursorType
來設置特定的系統點。例如,使用此設置箭頭類型:
您還可以使用資源文件添加自定義指針。詳情請見see this blogpost。
不,這不是可能隱藏光標,但你可以使用其他的圖標,如:
使用XAML按鈕,並添加類似按鈕控制內部PointerEntered
事件:
<Button Name="button" BorderThickness="2" PointerEntered="button_PointerEntered" PointerExited="button_PointerExited">Button</Button>
和C#代碼:
private void button_PointerEntered(object sender, PointerRoutedEventArgs e)
{
Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand, 1);
}
private void button_PointerExited(object sender, PointerRoutedEventArgs e)
{
Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 1);
}
我認爲自定義指針太乏味,我怎麼容易定製指針。 – lindexi