得到兄弟控制

时间:2012-09-18 15:03:02

标签: workflow-foundation-4

有没有办法找到兄弟控制/兄弟活动?

在ASP.NET中,我找到了用户md1337 solution's的解决方案,但对于WF4,我找不到它。

非常感谢。

1 个答案:

答案 0 :(得分:0)

 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;
                }
            }
        }
    }

在mi创建活动方法中我做:

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