datagridstylesrefreshavalonia

Avalonia DataGridCell not refreshed when using CellStyle


If I set a right-align style for my DataGridCell :

 <Style Selector="DataGridCell.right-align">
   <Setter Property="HorizontalAlignment" Value="Right" />
   <Setter Property="Padding" Value="0,0,4,0" />
 </Style>

I've got some serious issues in the Played column as you can see in the screenshots :

init without scrolling

or after sorting :

sorted without scrolling

but if I scroll down then up, to refresh the items everything is all right :

init after scrolling

sorted after scrolling

Another thing... the Length column also has the right-align Class, but use a Converter so I guest it's working because it's redrawn after using the converter

I obviously expect the text to not be cut... Thanks in advance.


Solution

  • It has been solved by modifying the style like

    <Style Selector="DataGridCell.right-align > TextBlock">
        <Setter Property="TextAlignment" Value="Right" />
        <Setter Property="Padding" Value="0,0,4,0" />
    </Style>
    

    I've tried this before but the class name wasn't at the right place

    <Style Selector="DataGridCell > TextBlock.right-align ">
        <Setter Property="TextAlignment" Value="Right" />
        <Setter Property="Padding" Value="0,0,4,0" />
    </Style>