How to scroll WPF ScrollViewer's content to specific location

前端 未结 4 921
清酒与你
清酒与你 2020-12-16 11:55

I am writing my custom WPF ItemsControl to display a list of item. The items are shown embedded inside a ScrollViewer:



        
4条回答
  •  死守一世寂寞
    2020-12-16 12:02

    // How to scroll the uiElement to the mouse position?
    uiElement.BringIntoView();
    

    REF: https://msdn.microsoft.com/en-us/library/ms598110.aspx

    UPDATE: (thanks to @jmbpiano) Note, it does not bring the control exactly to the current mouse cursor position. It just brings the control to a visible position, where the Operator will be able to click it with the mouse (which in 99% of cases is all someone who finds this question is likely to need).

提交回复
热议问题