【发布时间】:2011-05-18 02:07:08
【问题描述】:
我试图用项目填充 ListBox。 ItemsSource如下:
public SortedDictionary<string, List<int>> AvailableValues
当我有以下物品时,这些物品似乎布置得很好。除了我无法选择整个项目并对其执行某些功能。
<ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" >
<ItemsControl ItemsSource="{Binding AvailableValues}">
<ItemsControl.Template>
<ControlTemplate>
<CustomControls:UniformWrapPanel IsItemsHost="True"/>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="{Binding Key}" />
<ComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding Value}" SelectedItem="{Binding SelectedInputValue, UpdateSourceTrigger=PropertyChanged}" IsSynchronizedWithCurrentItem="True" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
我尝试用ListBox(以及ListBox.ItemTemplate)替换ItemsControl,但似乎无法显示Label Content 左对齐和Combobox 内容右对齐。
UniformWrapPanel 来自 CodeProject 文章。
谢谢,
【问题讨论】: