Click here to Skip to main content
Click here to Skip to main content

Tagged as

Synchronize ListBoxes easy

, 22 Sep 2010
Rate this:
Please Sign up or sign in to vote.
An easy answer;
I find out an easy way for Silverlight 4 to synchronize two ListBox or any that has a ScrollContentPresenter
I started with silverlightdatagridscroll article I modified the method GetScrollBar to this:
public ScrollContentPresenter GetScrollPresenter(DependencyObject dep)
            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(dep); i++)
                var child = VisualTreeHelper.GetChild(dep, i);
                if (child != null && child is ScrollContentPresenter)
                    return child as ScrollContentPresenter;
                    ScrollContentPresenter sub = GetScrollPresenter(child);
                    if (sub != null)
                        return sub;
            return null;
Now, I implemented the following in my code:
GetScrollPresenter(scrollViewer0).LayoutUpdated += (s1, e1) =>
        if(GetScrollPresenter(scrollViewer1)!=null && GetScrollPresenter(scrollViewer0) !=null)
And the last thing, in my case I have the following in the XAML:
<ScrollViewer Padding="10" x:Name="scrollViewer0" Style="{StaticResource PageScrollViewerStyle}" Margin="10">
            <ListBox x:Name="SourceList" Background="#FFE8F8FF" />


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


About the Author

Juan Pablo G.C.
Software Developer Expediteapps
Spain Spain
I'm Electronic Engineer, I did my end degree project at Astrophysical Institute and Tech Institute. I'm HP Procurve AIS and ASE ,Microsoft 3.5 MCTS
I live in Canary Islands ,developing customized solutions
I'm developing with WPF4, SL4 MVVM, MVC3 Razor and WP7 projects, more info at my websites. Improving with Android and IOS.

Take a look to my blog Juan Pablo G.C.

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 22 Sep 2010
Article Copyright 2010 by Juan Pablo G.C.
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid