Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can I get the scrolled item of Scrollviewer in WPF..?

I have assigned a List to Scrollviewer Content but want to get Scrolled item which is coming to ScrollintoView(?(index)),hence want to get front coming item cause i want to set index of Combobox according to scrolled item of Scrollviewer..
Posted
Updated 18-Apr-11 23:05pm
v2
Comments
Tarun.K.S 19-Apr-11 5:11am    
Are you using a ListBox inside the ScrollViewer?
[no name] 21-Apr-11 10:15am    
First Thanks for replying.
i am using stackpanel inside and while scrolling first touches the current seeing item and dont know how much items get scrolled. issue is to get scroll completed item and set to other...

1 solution

There is not such thing, and it would not make any sense.

Think by yourself. There is a property System.Windows.Controls.ContentControl.Content; something which is always in view, usually partially (because this is a purpose of System.Windows.Controls.ScrollViewer). Everything else fully depends on what is placed inside Content. You can always arrange controls inside ScrollViewer.Content and the size of ScrollViewer the way more than one control is always in the view. Which one would you consider as a "scrolled item"?

You can always calculate what part of control is currently visible based on ScrollViewer size, its scroll position and actual position/size of the control in question.

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 19-Apr-11 16:26pm    
Good points, my 5
Sergey Alexandrovich Kryukov 19-Apr-11 16:26pm    
Thank you, Espen.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900