Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

DataGrid: Are the features "Right-Justified" and "Sortable Rows" mutually exclusive?

$
0
0

I have looked hard and long all over the Internet for a way to right-justify my numerical columns. The ONLY one that has worked for me is to stay away from this way of coding (which is simple, nice and readable):

<DataGridTextColumn  Header="Total Height" Binding="{Binding Path=TotalHeight, StringFormat=0.00}" CellStyle="{StaticResource ReadOnlyCell}"></DataGridTextColumn>

opting instead for this one:

<DataGridTemplateColumn Header="Total Height" CellStyle="{StaticResource ReadOnlyCell}"><DataGridTemplateColumn.CellTemplate><DataTemplate><TextBlock TextAlignment="Right" Text="{Binding TotalHeight, StringFormat=0.00}"/></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn>

Frankly, I didn't care for the extra complexity, but I was willing to accept it as long as my columns were (finally!!) right-justified, after a LOT of failed experiments.

The new PROBLEM is that when designating the columns as DataGridTemplateColumn, they cannot be sorted by clicking on the header.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>