Click here to Skip to main content
12,953,544 members (52,293 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 28 Sep 2010

Silverlight Get REAL Visible Items in a Container (WrapPanel)

, 28 Sep 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Using this you can animate or change states of the actually visible items
In my case I have to change the state of just a few elements that are visible or partially visible of a big list in a wrappanel and I cannot force to animate 100 items instead of 12. So here is a way to make this:

<ScrollViewer x:Name="ScrollContainer"  >
     <toolkit:WrapPanel x:Name="WrappedButtons"/>

and the c#

UIElement MyUIE = ScrollContainer;
GeneralTransform gt = MyUIE.TransformToVisual(Application.Current.RootVisual as UIElement);
Rect rect = new Rect(gt.Transform(new Point(0, 0)), MyUIE.RenderSize);
var foundElements = VisualTreeHelper.FindElementsInHostCoordinates(rect, MyUIE);
Type MyType = typeof(Button);
if (foundElements != null)
        var listBoxItem = foundElements.Where(w => w.GetType().Equals(MyType)).ToList();
         TBResult.Text = listBoxItem != null ? listBoxItem.Count.ToString() : String.Empty;

And that's all try it, It successfully works.
(Of course as many tips is a mix and changes of stuffs from the internet)


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

Deeply involved in Xamarin Forms LOB (including Azure Cloud with offline support, custom controls, dependencies) projects, WP8.1 & W10 projects, WPF modern styled projects. Portable libraries like portablePDF, portableOneDrive, portableReports and portablePrinting (using Google Printing API).

Web and apps showcase at:

Take a look to my blog

You may also be interested in...

Comments and Discussions

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