![]() ![]() Private void OnRendering( object sender, EventArgs e)ĭebugTextBlock.Text = Mouse.GetPosition(DebugTextBlock).ToString() ĭebugButton.Content = Mouse.GetPosition(DebugButton).ToString() 1ĬompositionTarget.Rendering += OnRendering Now, we try to get mouse position relative to these two FrameworkElement with Mouse.GetPosition method. NET Core version, it contains a Button and Textblock. And this application is developed with default. Here is his Blog.Ĭreates a default WPF application with Visual Studio 2019. Waterlv is an MVP(Microsoft Most Valuable Professional), and he is good at. But this blog was written in Chinese, so I translate its content to English. This article is to tell developers about what and how we get the mouse coordinate. But, what will we get when the mouse is outside the window’s client area? And how does it calculate? One is Mouse.GetPosition(IInputElement relativeTo), the other is MouseEventArgs.GetPosition(IInputElement relativeTo). ![]() As we all know, we have two methods to get the mouse position which is relative to other controls. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |