c# - Clear all TextBox in Window -


I'm programming in C # (WPF) I have a lot of nested controls I want to clear the cleaner of my text box control which is in my application. It is very difficult to reach them by their name.

  Public Zero Clear All (Control C) {If (C Text Box) is (Text Box) c). Clear (); Return; } Leading (control child Gatechild (C)) {Clear all (children); }}    

The VisualTreeHelper class comes easy. You can use it like this:

  Fixed public Zero TraverseVisualTree (view myMainWindow) {int childrenCount = VisualTreeHelper.GetChildrenCount (myMainWindow); For (int i = 0; i & lt; kidsCount; i ++) {var visualchild = (Visual) VisualTreeHelper.GetChild (myMainWindow, i); If (Visual Child Text Box) {Text Box TB = (Text Box) VisualBold; tb.Clear (); } TraverseVisualTree (Visual Child); }}    

Comments

Popular posts from this blog

c# - passing input text from view to contoller with FacebookContext using Facebook app -

ios - Does Core Data autoupdate a many to many relationship on saving -

Calling a C++ function from C# by passing a string with variable size to it -