Jonathan Allen
Jonathan Allen

Reputation: 70327

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

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

Upvotes: 2

Views: 1097

Answers (1)

Patrick Klug
Patrick Klug

Reputation: 14411

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.

Upvotes: 9

Related Questions