我试图在弹出窗口的代码中将光标设置为none,但我无法让它工作。游标在弹出窗口上方时仍会显示。我做错了什么?
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;
}发布于 2018-05-29 13:05:21
不要将TextBlock的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的“背景”不属于您的应用程序,所以只有当鼠标指针移动到TextBlock中的实际文本上时,Cursors.None才会应用。
https://stackoverflow.com/questions/50569968
复制相似问题