Author: brucemartin | Posted on: 6/22/2008 6:20:06 PM | Views : 279

Some code of mine worked in Beta1, but does not work in Beta2. I have an UserControl where I define a stackpanel in xaml, then programmatically I add a variable number of canvases. Each canvas has rectangles, lines, textblocks. The elements in each canvas are assigned names so that they can be found later.

In Beta1 I could use "Result = StackPanel.FindName(ItemName)" to find one of the rectangles. But this fails to work in Beta2. Here is some code that I use now to find the rectangles as I need them:

    Private Function FindOutlineElementItem(ByVal Parent As Object, ByVal ItemName As String) As Object
        Dim TestResult1 = CType(Parent, StackPanel).FindName(ItemName) '<-test only-
        Dim nChildCount = Parent.Children.Count
        For i = nChildCount - 1 To 0 Step -1
       ...

Go to the complete details ...