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

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 2 months ago by William Leary
Version: 22.1.2
Avatar

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" 
                  IsReadOnly="True"
                  ItemsSource="{Binding CollectionView}">
            <datagrid:ThemedDataGrid.RowStyle>
                <Style TargetType="{x:Type DataGridRow}">
                    <EventSetter Event="MouseDoubleClick" Handler="SecurityDiplayDataGrid_MouseDoubleClick"/>
                    <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                </Style>
            </datagrid:ThemedDataGrid.RowStyle>
            <datagrid:ThemedDataGrid.Columns>
                <DataGridTextColumn Header="Name" Binding="{Binding Object.UserName}" Width="100" IsReadOnly="True"/>

Comments (2)

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

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 months ago by William Leary
Avatar

This worked! Thank you so much for the help. 

The latest build of this product (v22.1.3) was released 23 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.