Search code examples
workflow-foundation-4

get sibling controls


Is there some way to find sibling controls / or sibling activity?

In ASP.NET I found a solution by user md1337 solution's, but for WF4 I can't find it.

Thanks a lot.


Solution

  •  public static IEnumerable<T> FindVisualChildren<T>(System.Windows.DependencyObject depObj) where T : System.Windows.DependencyObject
        {
            if (depObj != null)
            {
                for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
                {
                    System.Windows.DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
                    if (child != null && child is T)
                    {
                        yield return (T)child;
                    }
    
                    foreach (T childOfChild in FindVisualChildren<T>(child))
                    {
                        yield return childOfChild;
                    }
                }
            }
        }
    

    And in mi Create Activity method I do:

     foreach (TextBlock tb in RulesDll.ObjectsClass.FindControls.FindVisualChildren<TextBlock>(target))
            {
                string a = tb.Text;
            }