locked
PointToClient in WPF RRS feed

  • Question

  • I get the contact position point pt = e.GetPosition(myImage)

    How do I convert this point to client coordinates? Kind of the way winforms works with PointToClient?

    Wednesday, September 15, 2010 7:56 PM

Answers

  • Hi Rgarf,

    You can use Visual.PointFromScreen method which is similar to winforms' Control.PointToClient method.

    You can see the documention at http://msdn.microsoft.com/en-us/library/system.windows.media.visual.pointfromscreen.aspx.

    And Visual.PointToScreen is similar to windforms' Control.PointToScreen method.

    Hope this helps.

    If you still have any doubts or concerns about this issue, please feel free to let me know.

    Best regards,

    Min

     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Min Zhu Thursday, September 23, 2010 1:16 AM
    Monday, September 20, 2010 8:21 AM

All replies

  • Hi,

    I think, you need a position with coordinated of your control, if it right then use

    ListBoxItem item = ListBoxName.ItemContainerGenerator.ContainerFromItem(ListBoxName.SelectedItem) as ListBoxItem;

    Point point = new Point();

    var r = item.PointToScreen(point);

    If it is not that you want, please ignore it.

    Thanks,

    Rajnikant

    Thursday, September 16, 2010 4:11 AM
  • Hi Rgarf,

    You can use Visual.PointFromScreen method which is similar to winforms' Control.PointToClient method.

    You can see the documention at http://msdn.microsoft.com/en-us/library/system.windows.media.visual.pointfromscreen.aspx.

    And Visual.PointToScreen is similar to windforms' Control.PointToScreen method.

    Hope this helps.

    If you still have any doubts or concerns about this issue, please feel free to let me know.

    Best regards,

    Min

     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Min Zhu Thursday, September 23, 2010 1:16 AM
    Monday, September 20, 2010 8:21 AM