How can I find all controls within a control(WPF, C#)? -
I get interesting questions about this kind of thing, but I want my method to return all control within me Ho. It does not make any difference to the name of the control or its type unless the method returns all those possible controls. ">
In these WinForms this is very easy ... just grab the WinForms container and then check 'Control' and return to the repository of the control archive .
foreach (system.indows.Forms.Control ctrl in form.Controls) {if (ctrl.Name == "tab page control") {// 'tab page controller object' Do something with {}
As you can see the deceased in WinForms easy, to get access to the global container to return a 'Control' Through or through depth if its panel or something happens.Once you find out what you want, you are simply making a list of the list that is anything with your list or your control.
WPF , it is slightly different I do not have a comprehensive WPF experience, but I came with it after 15 minutes of play:
Private Zero Button 1_Click (Object Sender, RoutedEventArgs e) {// Excluded Grid Object Grid grid = (grid) this.Content; // Simple test to know what type of string is s = grd.ToString (); // In VS, in debug mode, pop up 'grd.children' and 'smart tool tip' which // pops / says exactly under a 'counting' property how many controls are sitting on the global container It was just 1 for me, leading my button (UIDAILEMENT KIDS in Gda KIDS) {// do some more tests to ensure that there is correct control. In a statement pref but anyhooo string sss = child.GetType (). Full name; // Exclude the appropriate type. Button myWpfButton = (button) child; }}
I hope you have the hope to get started.
Comments
Post a Comment