How to get a WPF DataGrid cell to right align without making the selectable area on a new row tiny?

后端 未结 5 1691
走了就别回头了
走了就别回头了 2021-01-31 13:38

I\'m using a WPF4.0 DataGrid. When double clicking on a cell in a new row everything works fine unless I\'ve added a cell style to that column. For example, I h

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-31 14:10

    I just had a similar problem and found another solution by overwriting the Style for the DataGridCell in Blend.

    The changed items from the original style are the setters for VerticalAlignment and VerticalContentAlignment in the Style itself to stretch the cell itself and VerticalAlignment="Center" and HorizontalAlignment="Right" in the Template property to align the content. Change these values to whatever you need to align the cells content.

    The rest of the style could be removed so that the settings from the base style will be used (using the StaticResource the style is BasedOn). However I left the style as Blend produced it.

    This resulting XAML-Code should then be included into the controls resources:

    
    

提交回复
热议问题