0
我尝试为组合框执行模板。 ItemTemplate中是确定的,但不是选择的项目如u可以看到如下:组合框WPF模板项目和选定项目
我的代码:
<ComboBox ItemsSource="{Binding CouleursList}"
SelectedItem="{Binding SelectedCouleur}"
Grid.Column="1" Grid.Row="2">
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ComboBox.ItemContainerStyle>
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid>
<Rectangle Stroke="Black" Margin="1" Height="15"
HorizontalAlignment="Stretch">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Path=., Converter={StaticResource ColorConverter}}"/>
</Rectangle.Fill>
</Rectangle>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
如果我给了一个固定的宽度,即工作,但矩形是一致的左和中心的名单
谢谢!
OMG ......如此简单,我没有找到它... –