How to find a control with a specific name in an XAML UI with C# code?
问题 I have dynamic added controls in my XAML UI. How I can find a specific control with a name. 回答1: There is a way to do that. You can use the VisualTreeHelper to walk through all the objects on the screen. A convenient method I use (obtained it somewhere from the web) is the FindControl method: public static T FindControl<T>(UIElement parent, Type targetType, string ControlName) where T : FrameworkElement { if (parent == null) return null; if (parent.GetType() == targetType && ((T)parent).Name