Skip to content

DataGrid Selection Color Disappearing #1728

@Camuvingian

Description

@Camuvingian

I have a control which is essentially a DataGrid. These get housed on separate tabs in a TabControl via AvalonDock. The selection color is set correctly when each tab is loaded pre-MahApps V1.0.0.0, however having now updated to V1.0.0.0, when I switch tabs and then back to the previous one, the selected highlight color disappears, like the fore-color and background-color have both been set to transparent/white. See

datagridselectionerror

You can see when I select a different tab and return the selection color is changed and then when I scroll out and back into view the selection coloring returns. This seems like a virtualisation issue, but it is a problem that I can fix by setting options on my DataGrid. For reference, the XAML for this control is

<DataGrid x:Name="CoreGrid"
             Panel.ZIndex="0"
             HorizontalAlignment="Stretch"
             VerticalAlignment="Stretch"
             AutoGenerateColumns="True" 
             CanUserAddRows="False" 
             CanUserDeleteRows="True"
             SelectionUnit="Cell"
             EnableRowVirtualization="True" 
             EnableColumnVirtualization="True" 
             VirtualizingStackPanel.VirtualizationMode="Recycling" 
             SelectedItem="{Binding SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
             GridLinesVisibility="{Binding GridLinesVisibility}"
             Caliburn:Message.Attach="
                [Event CellEditEnding] = [Action CellEditEnding($this, $eventArgs)]; 
                [Event SelectedCellsChanged] = [Action SelectedCellsChanged($this, $eventArgs)]">
    <Interactivity:Interaction.Behaviors>
        <Behaviors:BindableSelectedItemsBehavior
            SelectedItems="{Binding SelectedItems, Mode=TwoWay}"/>
    </Interactivity:Interaction.Behaviors>  
    ...
</DataGrid>

I can confirm that this problem does not occur when I use the previous version of MahApps. How can I prevent the selection/highlight color disappearing?

Thanks for your time.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions