ComboBox in a ThemedDataGrid

Grids for WPF Forum

Posted 5 years ago by Tony Pal
Version: 19.1.0680
Avatar

Hi,

I have a ThemedDataGrid using the Dark Theme that has a DataGridComboBoxColumn.  When the DataGridComboBoxColumn is selected and expanded to select an item from it, it is White.  How do I make it match the theme of the ThemedDataGrid so that the user can see what they are selecting without hovering the mouse over each item.

<datagrid:ThemedDataGrid.Columns>
                        <DataGridTextColumn Binding="{Binding Extension}" ClipboardContentBinding="{x:Null}" Header="Extenstion"/>
                        <DataGridTextColumn Binding="{Binding TotalHeaderLines}" ClipboardContentBinding="{x:Null}" Header="Total Header Lines"/>
                        <DataGridTextColumn Binding="{Binding ParameterLine}" ClipboardContentBinding="{x:Null}" Header="Parameter Line"/>
                        <DataGridTextColumn Binding="{Binding GroupLine}" ClipboardContentBinding="{x:Null}" Header="Group Line"/>
                            <DataGridCheckBoxColumn Binding="{Binding DataColumn}" ClipboardContentBinding="{x:Null}" Header="Date Column"/>
                            <DataGridComboBoxColumn
                                ClipboardContentBinding="{x:Null}"
                                Header="Time Format"
                                SelectedValueBinding="{x:Null}"
                                SelectedItemBinding="{Binding TimeFormat}">
                                <DataGridComboBoxColumn.ElementStyle>
                                    <Style TargetType="{x:Type ComboBox}">
                                        <Setter Property="ItemsSource" Value="{Binding Path=DataContext.TimeFormatsList, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
                                    </Style>
                                </DataGridComboBoxColumn.ElementStyle>
                                <DataGridComboBoxColumn.EditingElementStyle>
                                    <Style TargetType="{x:Type ComboBox}">
                                        <Setter Property="Foreground" Value="Black"/>
                                        <Setter Property="Background" Value="Green"/>
                                        <Setter Property="ItemsSource" Value="{Binding Path=DataContext.TimeFormatsList, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
                                    </Style>
                                </DataGridComboBoxColumn.EditingElementStyle>
                            </DataGridComboBoxColumn>
                            <DataGridCheckBoxColumn Binding="{Binding DataColumn}" ClipboardContentBinding="{x:Null}" Header="Date Column"/>
                            <DataGridComboBoxColumn
                            ClipboardContentBinding="{x:Null}"
                            Header="Delimeter"
                            SelectedValueBinding="{x:Null}"
                            SelectedItemBinding="{Binding Delimeter}"
                            TextBinding="{x:Null}" />
                        <DataGridTextColumn Binding="{Binding Unit}" ClipboardContentBinding="{x:Null}" Header="Unit"/>
                        <DataGridTextColumn Binding="{Binding LapMarker}" ClipboardContentBinding="{x:Null}" Header="Lap Marker"/>
                    </datagrid:ThemedDataGrid.Columns>
                    <datagrid:ThemedDataGrid.AlternatingRowBackground>
                        <SolidColorBrush Color="#3CF4F4F4" themes:TintGroup.Name="List"/>
                    </datagrid:ThemedDataGrid.AlternatingRowBackground>
                </datagrid:ThemedDataGrid>

Comments (3)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tony,

Can you send our support address a new simple sample that shows this happening so we can debug with it and make sure anything we update properly fixes it for your scenario?  Please reference this thread, remove the bin/obj folders from the ZIP you send, and rename the .zip file extension so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 5 years ago by Tony Pal
Avatar

Hi,

I cannot send a sample of the project, it is too large.  I wish that I could send a screen shot but there I don't see an option to send you that.  Is there a way to do so.  The above XAML shows what I am doing.

Thank you

Answer - Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tony,

This is happening because the ComboBox that the Microsoft DataGrid creates is not getting allowed to inherit our default implicit Style from our theme, so it's using the normal theme for the control.  You can work around it by doing this, which will force it to use our theme:

<DataGridComboBoxColumn ...>
	<DataGridComboBoxColumn.EditingElementStyle>
		<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Static themes:SharedResourceKeys.EmbeddedComboBoxStyleKey}}" />
	</DataGridComboBoxColumn.EditingElementStyle>
</DataGridComboBoxColumn>


Actipro Software Support

The latest build of this product (v24.1.2) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.