<Window.Resources>
<ObjectDataProvider ObjectInstance="{x:Type Colors}" MethodName="GetProperties" x:Key="colorPropertiesOdp" />
</Window.Resources>
<Grid>
<ComboBox Name="comboBox1"
ItemsSource="{Binding Source={StaticResource colorPropertiesOdp}}"
Margin="100,115,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Height="30"
Width="295" >
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Rectangle Fill="{Binding Name}" Width="60" Height="20" Margin="0,3,0,3"></Rectangle>
<TextBlock Text="{Binding Name}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,0,0,0"></TextBlock>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
WPF Color ConboBox
最新推荐文章于 2023-12-29 11:00:54 发布