Wpf

WPFは名前で親子コントロールを検索します



Wpf Find Parent Child Controls Name



VisualTreeHelperのGetChildrenCountメソッドとGetChildメソッドを使用してオブジェクトの子コントロールを検索し、GetParentメソッドを使用してオブジェクトの親を検索します。

public T FindChild(DependencyObject parent, string childName)where T : DependencyObject { if (parent == null) return null T foundChild = null int childrenCount = VisualTreeHelper.GetChildrenCount(parent) for (int i = 0 i
|_+_|