我有一个组合框,XAML中有一个小模板,如下所示:
<ComboBox Name="cboStyles" Grid.Column="1" Grid.Row="5">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="15" Width="Auto">
<!-- Don't know what to do here. -->
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
我想在那里填充一些带有不同边框样式的矩形,如虚线和点缀。更好的是从C#中的代码填充它。 感谢。
答案 0 :(得分:0)
这就是你想要的:
<ComboBox Name="cboStyles" Grid.Column="1" Grid.Row="5" Height="100">
<Rectangle Stroke="Black" Margin="5" Width="50" Height="50" StrokeDashArray="5" StrokeThickness="2" StrokeDashOffset="2"></Rectangle>
<Rectangle Stroke="Blue" Margin="5" Width="50" Height="50" StrokeDashArray="5" StrokeThickness="2" StrokeDashOffset="2"></Rectangle>
<Rectangle Stroke="Green" Margin="5" Width="50" Height="50" StrokeDashArray="5" StrokeThickness="2" StrokeDashOffset="2"></Rectangle>
<Rectangle Stroke="Red" Margin="5" Width="50" Height="50" StrokeDashArray="5" StrokeThickness="2" StrokeDashOffset="2"></Rectangle>
</ComboBox>
这是结果: