I have 4 List Boxes in my WPF App. Each of them, at any given point of time contains equal no. of String ListBoxItems in them. If selected index of any one of them changes the other three also reflect the same behaviour. What i want is that when a user moves scrollbar of one of them the other three should also move simultaneoulsly.
I tried Scrollintoview but it does not work bcoz if i select an item of a listBox and apply scrollintoview for other three Listboxes the selected item in them come on the top.
That's why i think scrollbar movement should be the best option for this. How to do that?
Well in code it is something like that :
1) get the four scrollviewers of the four ListViews ( by finding them within the child (VisualTreeHelper.getchild) inside a method like FindDescendant(...))
2) hook their scrolls events (ScrollChanged) to a common sub that will get the VerticalOffset of the one that triggered the event and ScrollToVerticalOffset(.) the others.
must be possible in xaml also, but seems more complicated to me.
In XAML hook the ScrollChanged event
In CodeBehind find the Scrollviewers inside the ListBoxes and apply the Vertical offset: