2011-09-01 33 views
0

我是新來WPF和會計應用程序的工作,我的問題是如此的簡單而我感到驚訝的是,我不能找到這一個簡單的解決方案,它是這樣的:定製的Datagrid在WPF

我有創建一個只有列應該有可見邊框的數據網格。我的意思是它應該是這個樣子:

| col1 | col2| col3| 

|  |  |  | 

|  |  |  | 

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

我做了一切我能做的,但我實現了這個:

enter image description here

我不明白爲什麼我的垂直線不要觸摸邊框.. .....

那朵是我使用生成DataGrid中的XAML:

<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> 

感謝您的考慮....

回答

0

您需要更改DataGriddefault Template,因爲除了水平滾動條外,最後一行的下方沒有任何東西被創建。

+0

那麼你是否告訴我,沒有簡單的方法來完成這個小小的基本定製...是不是有點奇怪,我的意思是我認爲這應該是相當普遍的行爲...... – Sudh

+0

@ Sudh:是的,這正是我告訴你的,而且這幾乎是WPF第一次有些奇怪的事情...... –