Different layout in last row of datagrid

0

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>
    
asked by anonymous 21.08.2017 / 16:53

1 answer

0

I created another property with the settings I needed, so as the others are not populated in this case, the value matched well.

<TextBlock Text="{Binding Officer1Percentagem}" TextAlignment="Center" Grid.Column="0" Grid.ColumnSpan="3"/>
<TextBlock Text="{Binding Officer1Abertura}" TextAlignment="Right" Grid.Column="0"/>
<TextBlock Text="{Binding Officer1Fechamento}" TextAlignment="Right" Grid.Column="2"/>
    
21.08.2017 / 18:01