在我的应用程序中,我为ComboBox创建了一个DataTemplate。 (请参阅下面的XAML。)我想将此样式应用于应用程序中的多个ComboBox。我怎么能这样做?
<ComboBox Name="mouseColorCmbx" AutomationProperties.AutomationId="SimulationOptionsPanel_mouseColorCmbx" Grid.Column="1" Grid.Row="0" Margin="0 0 0 0" HorizontalAlignment="Stretch" VerticalAlignment="Center">
<ComboBox.ItemTemplate>
<DataTemplate DataType="Forms:ColorInfo">
<StackPanel Orientation="Horizontal" Margin="0,3,0,0">
<Border Margin="2,0,2,0" BorderThickness="1">
<Border.BorderBrush>
<SolidColorBrush Color="Black"/>
</Border.BorderBrush>
<Border.Background>
<SolidColorBrush Color="{Binding Path=Color}"/>
</Border.Background>
<Rectangle Height="10" Width="25"/>
</Border>
<TextBlock Text="{Binding Path=Name}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>