Cursor = Cursors.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;

    }


手掌心
浏览 206回答 1
1回答

一只甜甜圈

不要将 的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.
打开App,查看更多内容
随时随地看视频慕课网APP