This question is locked. New answers and comments are not allowed.
Hi,
I have placed a large number of controls inside a grid on a RadExpander control.
I would like to loop on all the child controls that i have in the RadExpander and hook up event handlers on the controls found. I know the VisualTreeHelper is supposed to do the job but for some reason however the controls are never getting hooked up.
This is my code... PropPanel is a stackpanel that contains all of the expander controls, i am using a stack object to avoid recursivity
I have placed a large number of controls inside a grid on a RadExpander control.
I would like to loop on all the child controls that i have in the RadExpander and hook up event handlers on the controls found. I know the VisualTreeHelper is supposed to do the job but for some reason however the controls are never getting hooked up.
This is my code... PropPanel is a stackpanel that contains all of the expander controls, i am using a stack object to avoid recursivity
Stack<FrameworkElement> visualstack = new Stack<FrameworkElement>(); visualstack.Push(PropPanel); while (visualstack.Count > 0) { FrameworkElement child = visualstack.Pop(); int count = VisualTreeHelper.GetChildrenCount(child); for (int cnt = 0; cnt < count; cnt++) { FrameworkElement el = (FrameworkElement)VisualTreeHelper.GetChild(child, cnt); if (el is tc.RadNumericUpDown) ((tc.RadNumericUpDown)el).ValueChanged += PropertyPanelValueChanged; else if (el is TextBox) ((TextBox)el).TextChanged += PropertyPanelTextChanged; else if (el is tc.RadColorPicker) ((tc.RadColorPicker)el).SelectedColorChanged += PropertyPanelSelectedColorChanged; else if (el is ComboBox) ((ComboBox)el).SelectionChanged += PropertyPanelComboSelectionChanged; else if (el is Button && !(el is CheckBox)) ((Button)el).Click += PropertyPanelButtonClick; else if (el is ToggleButton && !(el is CheckBox)) ((ToggleButton)el).Click += PropertyPanelToggleButtonClick; else if (el is CheckBox) { ((CheckBox)el).Checked += PropertyPanelChecked; ((CheckBox)el).Unchecked += PropertyPanelChecked; } else visualstack.Push(el); } }
Can anyone tell me what i'm missing, why are the controls notbeing hooked up?
