如何在水平Silverlight列表框中均匀地分隔项目
在Silverlight中,我有一个垂直的列表框,每个项目都有一个水平的列表框。我希望水平列表框中的项目在父垂直列表框的宽度上均匀分布。我该怎么做如何在水平Silverlight列表框中均匀地分隔项目,silverlight,Silverlight,在Silverlight中,我有一个垂直的列表框,每个项目都有一个水平的列表框。我希望水平列表框中的项目在父垂直列表框的宽度上均匀分布。我该怎么做 <ListBox x:Name="MachineListBox" Background="Green"> <ListBox.ItemTemplate> <DataTemplate> <ListBox ItemsSource="{Bindin
<ListBox x:Name="MachineListBox" Background="Green">
<ListBox.ItemTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding CoilList}" Background="Red" HorizontalAlignment="Stretch">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel
HorizontalAlignment="Stretch" />
</ItemsPanelTemplate >
</ListBox.ItemsPanel>
<ListBox.ItemTemplate >
<DataTemplate>
<TextBlock
Text="{Binding Coil}"
HorizontalAlignment="Stretch"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我将冒昧地建议您使用我自己发明的自定义控件。它被称为比例面板,它只做您需要的事情—均匀地分隔项目。您可以将其用于内部列表框中的ItemsPanel,而不是StackPanel。我还提供了源代码,因此您可以随意调整逻辑。我博客上的相关帖子是。我认为比例大小操作符会满足您的要求。我还没试过,但听起来像是个选择。宽度=*和边距=2*比例面板链接现在已断开。请更新您的答案。