I have datagrid
where I show values referring to the beginning and end of a period. For this, I created columntemplate
down with 2 textblocks
, but in the last line, I show a value that is the difference between these 2 first values. I would like to center the first textblock on the last line since only it is populated in that case.
<DataGridTemplateColumn>
<DataGridTemplateColumn.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}, Path=DataContext.Officer11Nome}"
HorizontalAlignment="Center"
Grid.Column="0"
Grid.Row="0"
Grid.ColumnSpan="3"
/>
<TextBlock Text="Abertura"
HorizontalAlignment="Center"
Grid.Column="0"
Grid.Row="1"
/>
<TextBlock Text="Fechamento"
HorizontalAlignment="Center"
Grid.Column="2"
Grid.Row="1"
/>
</Grid>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Officer1Abertura}" Margin="2,0,2,0" TextAlignment="Left" Grid.Column="0"/>
<TextBlock Text="{Binding Officer1Fechamento}" Margin="2,0,2,0" TextAlignment="Right" Grid.Column="2"/>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>