Windows phone 8 在WP8中将ItemsPanelTemplate设置为动态创建的ListBox
我在WP8中有一个列表框控件Windows phone 8 在WP8中将ItemsPanelTemplate设置为动态创建的ListBox,windows-phone-8,listbox,Windows Phone 8,Listbox,我在WP8中有一个列表框控件 <ListBox> <ListBox.ItemsPanel> <ItemsPanelTemplate> <toolkit:WrapPanel Height="120" Width="410" Orientation="Horizontal" /> </ItemsPanelTemplate> </ListBox.ItemsPanel
<ListBox>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel Height="120" Width="410" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem Margin="0,0,20,0" Width="120" Height="120" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
ListBoxItem 1
</ListBoxItem>
<ListBoxItem Margin="0,0,20,0" Width="120" Height="120" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
ListBoxItem 2
</ListBoxItem>
<ListBoxItem Margin="0,0,10,0" Width="120" Height="120" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
ListBoxItem 3
</ListBoxItem>
</ListBox>
现在我必须在运行时添加这个列表框。我可以设法添加ListBoxItems,但无法设置ItemsPanelTemplate。请帮忙
ListBox lb = new ListBox();
ItemsPanelTemplate ddd = new ItemsPanelTemplate();
lb.ItemTemplate = ddd;
xaml中的所有内容都是类。记住它。谢谢你的回答。但是如何在ddd中添加包装物呢?有不同的方法-。