How to customize the RowStyle of a ThemedDataGrid without losing the theme

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 2 years ago by William Leary
Version: 22.1.2

We are just starting to use ThemedDataGrid for visual consistency with the Actipro themes.

A problem we are having is if we have controls that are modifying the RowStyle of the ThemedDataGrid (such as adding events or additional data bindings), the ThemedDataGrid loses the theme. In the below you'll see some code we are using to detect when a row is double-clicked and to set the IsSelected property of the row's view model when the row is selected. If this code is present, the ThemedDataGrid does not correctly apply themes to the rows. If I remove the lines that set the RowStyle, then the ThemedDataGrid looks correct. I can't find in the documentation how to modify the style of rows in a ThemedDataGrid. Hoping someone can point me in the right direction. Thanks!

<datagrid:ThemedDataGrid Grid.Row="1" Name="MyDataGrid" Margin="5" AutoGenerateColumns="False" 
                  ItemsSource="{Binding CollectionView}">
                <Style TargetType="{x:Type DataGridRow}">
                    <EventSetter Event="MouseDoubleClick" Handler="SecurityDiplayDataGrid_MouseDoubleClick"/>
                    <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTextColumn Header="Name" Binding="{Binding Object.UserName}" Width="100" IsReadOnly="True"/>

Comments (2)

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

Hi William,

You might be able to add this to your Style you set to the RowStyle:

BasedOn="{StaticResource {x:Static themes:DataGridResourceKeys.DataGridRowStyleKey}}"

Then that way, you'd inherit everything we define for your Style.

Actipro Software Support

Posted 2 years ago by William Leary

This worked! Thank you so much for the help. 

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

Add Comment

Please log in to a validated account to post comments.