2

I am using the DataGrid2D posted here. I can't seem to figure out a way to align the Text inside the Cells (i.e. right, center, left). For the default WPF4 DataGrid I just set

<Style x:Key="GridTextColumnStyleLeftAligned" TargetType="TextBlock">
   <Setter Property="TextAlignment" Value="Left" />
   <Setter Property="Margin" Value="2" />
   <Setter Property="TextWrapping" Value="WrapWithOverflow" />
   <Setter Property="VerticalAlignment" Value="Center" />
</Style>

Here TextAlignment does the trick. But when using the ItemsSource2D Property to bind it to a 2-dimensional Array this does not work anymore.

Does anybody have a suggestion?

Community
  • 1
  • 1
metacircle
  • 2,438
  • 4
  • 25
  • 39

1 Answers1

0

I found the problem: I am using the Alternative Style which the DataGrid2D Provides. There we already have this definiton:

<Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}" >
        <Setter Property="TextBlock.TextAlignment" Value="Center" />
...

If I change it here it works. I will have to rewrite the class a bit, for me to set the Alignment in XAML instead of with a style.

metacircle
  • 2,438
  • 4
  • 25
  • 39