Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the WPF equivalent of Silverlight's ScrollViewer.ScrollIntoView?

Tags:

wpf

What is the WPF equivalent of Silverlight's ScrollViewer.ScrollIntoView?

like image 585
Jonathan Allen Avatar asked Jan 29 '26 16:01

Jonathan Allen


1 Answers

The FrameworkElement class implements a BringIntoView() method - if you are dealing with a class that inherits from FrameworkElement you should be able to call that method. The method essentially raises the RequestBringIntoViewEvent which will bubble up the visual tree. The ScrollViewer and a bunch of other classes handle the event and then call their internal logic to bring the element into view.

Also some ItemControls such as DataGrid or ListBox provide a ScrollIntoView() method to make a child visible.

The ScrollIntoView() in turns calls the OnBringItemIntoView method in the ItemsControl class and in turn calls the FrameworkElement but also deals with a VirtualizingPanel where you might not have a FrameworkElement already created.

like image 197
Patrick Klug Avatar answered Jan 31 '26 07:01

Patrick Klug



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!