Reputation: 4185
I have this style defined in <UserControl.Resources>
:
<Style x:Name="DropDownStyle" TargetType="{x:Type ComboBoxItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5,2,2,2" Text="{Binding ID, Mode=OneWay}" />
<TextBlock Margin="5,2,10,2" Text="{Binding Name, Mode=OneWay}" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
which is used to display the items of the ComboBoxItem as 1 Car
, 2 Truck
, etc.
I would like to know how to move this style within the DataGridComboBoxColumn
item as this style is being applied to all my other DataGridComboBoxColumn
.
I cannot figure out how to get down to the ComboBoxItem
element of the DataGridComboBoxColumn
to apply the style.
Upvotes: 1
Views: 1688
Reputation: 2529
I see. You can accomplish what you want in the following way. Keep the existing ComboBoxItem
style where it is. Add another style for a Combobox, in the example below it is MyComboBoxStyle´ and refore to the
EditingElementStyle´ in your DataGridComboBoxColumn
.
<Style x:Key="MyComboboxStyle" TargetType="{x:Type ComboBox}">
<Setter Property="ItemContainerStyle" Value="{StaticResource DropDownStyle}"/>
</Style>
<DataGridComboBoxColumn EditingElementStyle="{StaticResource MyComboboxStyle}" SelectedItemBinding="{Binding MySelectedItem}" ItemsSource="{StaticResource MyArray}">
Upvotes: 1