none
Canvas mouse move get location information RRS feed

  • Question

  • I try to get my TabControl it contain dynamicly allocate TabItem

    Each TabItem content has its canvas

    I want mouse move on each canvas can show mouse location 

    For windows form it doesn't have canvas so I get tabPage location

    Windows Form Code like

    page[0].MouseMove += pageMouseMove;
    
    //
    
    private void pageMouseMove(object sender, MouseEventArgs e)
    {
                
        TextBox.Text = (e.Location.ToString());
    }       

    page is TabPage and it can show location on which tabPage I choose

    But WPF doesn't have MouseEventArgs e thiss argument

    How to get each tabItem content canvas's location showing on textBox .


    • Edited by CY_Chen Monday, August 26, 2019 12:15 AM
    Thursday, August 15, 2019 9:30 AM

Answers


  • Hi    CY_Chen,

    >>I try to get my TabControl it contain dynamicly allocate TabItem

    Each TabItem content has its canvas

    I want mouse move on each canvas can show mouse location 


    You can use the following code to get the position of the mouse pointer is calculated relative to the specified element with the upper-left corner of element being the point of origin,

    Point p = Mouse.GetPosition(canvas);

    Get Mouse Position on Canvas (But NOT on window)?

    How do I get the current mouse screen coordinates in WPF?


    Best regards

    Yong Lu




    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by CY_Chen Friday, August 23, 2019 10:21 AM
    Friday, August 16, 2019 1:41 AM
    Moderator