我试图在弹出窗口的代码中将光标设置为无,但我无法让它工作。光标在弹出窗口上方时仍会显示。我究竟做错了什么?public void SubWindow_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { TextBlock popupText = new TextBlock(); popupText.Text = "Complete" ; popupText.Background = Brushes.Transparent; popupText.Foreground = Brushes.White; popupText.Width = 130; popupText.FontSize = 30; popupText.IsHitTestVisible = false; popupText.Cursor = Cursors.None; Popup Popup = new Popup(); Popup.AllowsTransparency = true; Popup.PlacementRectangle = new Rect(1086, 16, 0, 0); Popup.IsHitTestVisible = false; Popup.Cursor = Cursors.None; Popup_Text.Child = popupText; Popup.IsOpen = true; }
1 回答
一只甜甜圈
TA贡献1836条经验 获得超5个赞
不要将 的IsHitTestVisible属性设置TextBlock为false:
TextBlock popupText = new TextBlock();
popupText.Text = "Complete";
popupText.Background = Brushes.Transparent;
popupText.Foreground = Brushes.White;
popupText.Width = 130;
popupText.Height = 130;
popupText.FontSize = 30;
//popupText.IsHitTestVisible = false;
popupText.Cursor = Cursors.None;
Popup Popup = new Popup();
//Popup.AllowsTransparency = true;
Popup.PlacementRectangle = new Rect(1086, 16, 0, 0);
Popup.IsHitTestVisible = false;
Popup.Cursor = Cursors.None;
Popup.Child = popupText;
Popup.IsOpen = true;
另请注意,您的应用程序只能在光标实际位于应用程序元素之一上时更改光标。透明的“背景”Popup不属于您的应用程序,因此Cursors.None仅当您将鼠标指针移到TextBlock.
- 1 回答
- 0 关注
- 205 浏览
添加回答
举报
0/150
提交
取消