Tag: 清除

清除Window中的所有TextBox

我用c#(WPF)编程。 我有很多nested controls 。 我想clear all我的应用程序中的clear all TextBox控件。 通过他们的名字访问它们非常困难。 有没有办法以recursively方式访问它们并清除它们? 例如这样的事情: public void ClearAll(Control c) { if(c is TextBox) { ((TextBox)c).Clear(); return; } foreach(Control child in GetChild(c)) { ClearAll(child); } }