-1

I would like to make a simple foreach loop with existing controller names in a simple WPF.

For example I have these:

<TextBlock x:Name="Label3" Text="Vasalás" HorizontalAlignment="Center" Grid.Column="2"/>
<ComboBox x:Name="LanguageSelectorCombo" Grid.Column="3" Margin="40 0 40 0" SelectedIndex="0" SelectionChanged="LanguageSelectorCombo_SelectionChanged">
    <ComboBoxItem>
        <TextBlock x:Name="Options1" Foreground="Black" Text="Hungarian"/>
    </ComboBoxItem>

Here I would like to get Label3, LanguageSelectorCombo and Options1.

g.mark11
  • 106
  • 5
  • 19

1 Answers1

1

I don't think there is simple foreach loop. You will need to use LogicalTreeHelper.GetChildren(parentControl) recursively to get all children controls. VisualTreeHelper might also help you to get specific child control.

kurakura88
  • 2,185
  • 2
  • 12
  • 18