0

I am new to wpf and working on an accounting application, My problem is so simple yet I am astonished that I can not find a simplistic solution for this, it goes like this:

I have to create a datagrid in which only columns should have visible borders. I mean it should look something like this:

 | col1 | col2| col3|

 |      |     |     |

 |      |     |     |

 |-----|------|-----|

I did everything I could do but I achieved this:

enter image description here

I dont understand why my vertical lines do not touch the border.......

tis is the xaml I am using to generate the datagrid:

<DataGrid Grid.Row="1" AutoGenerateColumns="False" x:Name="dataGrid1" VerticalAlignment="Stretch"
        CanUserReorderColumns="False" GridLinesVisibility="None" HorizontalGridLinesBrush="White"
        VerticalGridLinesBrush="White" Background="Transparent" Foreground="White" CanUserResizeRows="False"
        BorderBrush="White" BorderThickness="2" RowBackground="#FF008284" MinRowHeight="5" FontSize="14"
        ItemsSource="{Binding  }" Margin="8" SelectionMode="Single">
    <DataGrid.Resources>
        <Style TargetType="{x:Type DataGridColumnHeader}">
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
            <Setter Property="Background" Value="#FF008284" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Visibility" Value="Visible" />
            <Setter Property="Height" Value="40" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="BorderThickness" Value="1,1,1,1" />
            <Setter Property="BorderBrush" Value="White" />
        </Style>
        <Style TargetType="{x:Type DataGridCell}">
            <Setter Property="BorderThickness" Value="1,0,1,0" />
            <Setter Property="BorderBrush" Value="White" />
            <Setter Property="TextBlock.TextAlignment" Value="Center" />
            <Setter Property="Height" Value="30" />
            <Setter Property="HorizontalContentAlignment" Value="Right" />
            <Setter Property="TextBlock.FontSize" Value="14" />
        </Style>
    </DataGrid.Resources>
    <DataGrid.Columns>
        <DataGridTextColumn Width="120*" Header="Account Head" CanUserResize="False" CanUserReorder="False"
                CanUserSort="False" Binding="{Binding Path=AC_NAME}" />
        <DataGridTextColumn Width="60*" Header="Category" CanUserResize="False" CanUserReorder="False"
                CanUserSort="False" Binding="{Binding Path=AC_CATE}" FontSize="16" />
        <DataGridTextColumn Width="80*" Header="Debit" CanUserResize="False" CanUserReorder="False" CanUserSort="False"
                Binding="{Binding Path=AC_TOT_DR}" FontSize="16" />
        <DataGridTextColumn Width="80*" Header="Credit" CanUserResize="False" CanUserReorder="False" CanUserSort="False"
                Binding="{Binding Path=AC_TOT_CR}" FontSize="16" />
    </DataGrid.Columns>
</DataGrid>

Thanks for the consideration....

H.B.
  • 166,899
  • 29
  • 327
  • 400
Sudh
  • 1,265
  • 2
  • 19
  • 30

1 Answers1

0

You would need to change the default Template of the DataGrid as nothing is being created below the last row except a horizontal ScrollBar.

Community
  • 1
  • 1
H.B.
  • 166,899
  • 29
  • 327
  • 400
  • So are you telling me there is no simple way to accomplish this petty basic customization...isn't it a bit odd??, I mean I think it should be pretty common behavior...... – Sudh Sep 01 '11 at 21:38
  • @Sudh: Yes, that is exactly what i am telling you, and it's hardly the first time there is something odd about WPF... – H.B. Sep 01 '11 at 23:19