查找XAML中控件(递归)

           Window window = null;

            using (FileStream fs = new FileStream("MyWindow.xaml", FileMode.Open, FileAccess.Read))

            {

                window = (Window)System.Windows.Markup.XamlReader.Load(fs);

            }

            System.Windows.Controls.Button btnOk = (System.Windows.Controls.Button)window.FindName("btnOk");

原文地址:https://www.cnblogs.com/quietwalk/p/2262595.html