I define my ItemsControl
that contain RadioButton
s.
I want to access the Items
contained in ItemsControl
that are attached as binding child - and when I try to access the ItemsControl.Items
I can't see the RadioButtons
.
The code:
<ItemsControl Name="itemsControl" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton Content="{Binding Key}" />
</DataTemplate>
</ItemsControl开发者_StackOverflow.ItemTemplate>
</ItemsControl>
This is because you are setting the ItemTemplate of the control, ant not its items. To add items do it like this:
<ItemsControl Name="itemsControl" >
<ItemsControl.Items>
<RadioButton Content="{Binding Key}" />
</ItemsControl.Items>
</ItemsControl>
精彩评论