我有这个应用程序,我可以在其中插入图像并移动它们。
我想要的是能够在某些网格聚焦于键盘上的向上/向下箭头时调整它们的大小。
我曾尝试将此功能添加到 KeyDown 中,但它不起作用
UIElement_OnKeyDown(object sender, KeyRoutedEventArgs e)
在此之后,我在网上看到了一些评论并尝试使用
Window.Current.CoreWindow.KeyDown += UIElement_OnDownKey;
但我不知道如何通过这个以功能为中心的元素并调整它的大小,因为我最终得到了
CoreWindow sender, KeyEventArgs e
元素
谢谢!
只需添加即可完成我的意图
private async void UIElement_OnDownKey(CoreWindow sender, KeyEventArgs e)
{
Image myImage = GetFrontImage();
switch(e.VirtualKey)
{
case Windows.System.VirtualKey.Down: //Same thing for Up.
{
myImage.Width = myImage.Width * 0.98;
myImage.Height = myImage.Height * 0.98;
break;
}
}
}
GetFrontImage() 获取鼠标光标下的图像,我设置如下:
img.PointerEntered += setFocuse; // setFocuse function sets this image to be the one returned by GetFrontImage() function
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句