/// <summary>
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="parent"></param>
        /// <returns></returns>
        public IEnumerable<T> FindChildren<T>(DependencyObject parent) where T : class
        {
            var count = VisualTreeHelper.GetChildrenCount(parent);
            if (count > 0)
            {
                for (var i = 0; i < count; i++)
                {
                    var child = VisualTreeHelper.GetChild(parent, i);
                    var t = child as T;
                    if (t != null)
                        yield return t;

                    var children = FindChildren<T>(child);
                    foreach (var item in children)
                        yield return item;
                }
            }
        }

相关文章:

  • 2022-12-23
  • 2022-01-03
  • 2021-06-05
  • 2021-11-22
  • 2021-12-04
  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
  • 2022-12-23
  • 2022-03-04
相关资源
相似解决方案