Panel's Children as ComboBox's ItemsSource

151 Views Asked by At

In WPF I can do use a Panel's Children collection as the ItemsSource of a ComboBox:

WPF Panel's Children as ComboBox's ItemsSource

But in UWP this throws exception: "The parameter is incorrect." & vbCrLf

The Code-XAML:

<StackPanel>

<StackPanel Name="Panel1">

<TextBox Text="Item 1" />

<TextBox Text="Item 2" Margin="0,10,0,0" />

</StackPanel>

<ComboBox Margin="0,10,0,0" Name="Combo1" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Text}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>

</StackPanel>

The Code-Behind:

Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded

Combo1.ItemsSource = Panel1.Children

End Sub

How can i achieve the same goal at UWP?

0

There are 0 best solutions below