Reputation: 63
I'm not too familiar with C# or XAML, but I have a DataGrid that sets the Horizontal Grid Lines to be transparent. However, I would need to have the last row's bottom grid line of the DataGrid to be a solid line and not Transparent.
DataGrid is within a Grid and I tried setting the Border thickness value to be "0,0,0,1" on the off chance that it would work, but didn't. Tried to add some conditional statements to check for the last row of the DataGrid, but the way the code is built, there's no particular way to determine if it is the last row.
Current Style for the DataGrid
<Style x:Key="OrderViewDataGridStyle" TargetType="DataGrid">
<Setter Property="SelectionMode" Value="Single"/>
<Setter Property="SelectionUnit" Value="FullRow" />
<Setter Property="CanUserSortColumns" Value="True"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="AlternationCount" Value="2"/>
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="HorizontalGridLinesBrush" Value="Transparent"/>
<Setter Property="VerticalGridLinesBrush" Value="#CDCDCD"/>
<Setter Property="ColumnHeaderStyle" Value="{StaticResource DatagridColumnHeaderStyle}"/>
<Setter Property="ItemContainerStyle" Value="{StaticResource OrderViewDatagridRowStyle}"/>
<Setter Property="CanUserReorderColumns" Value="False"/>
<Setter Property="CanUserResizeColumns" Value="True"/>
<Setter Property="Background" Value="#F6F6F6"/>
<Setter Property="BorderBrush" Value="#CDCDCD"/>
<Setter Property="AutoGenerateColumns" Value="False"/>
<Setter Property="RowHeaderWidth" Value="0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="VirtualizingStackPanel.VirtualizationMode" Value="Recycling" />
<Setter Property="VirtualizingStackPanel.IsVirtualizing" Value="True" />
<Setter Property="EnableRowVirtualization" Value="True"/>
<Setter Property="EnableColumnVirtualization" Value="False"/>
</Style>
DataGrid
<Grid>
<Grid>
<Border>
...
<Border/>
<DataGrid>
<DataGrid.Columns>
...
<DataGrid.Columns/>
<DataGrid/>
<DataGrid>
<DataGrid.Columns>
...
<DataGrid.Columns/>
<DataGrid/>
<DataGrid>
<DataGrid.Columns>
...
<DataGrid.Columns/>
<DataGrid/>
<Grid/>
<Grid/>
I'm trying to see if there's a better way of implementing the one line at the bottom side of the last row without conditional xaml statements.
Upvotes: 1
Views: 1148
Reputation: 190
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<DataGrid GridLinesVisibility="Vertical"
BorderBrush="Black"
Background="White"
BorderThickness="0 0 0 1"
DataContext="{Binding ElementName=win}"
ItemsSource="{Binding itemList}"
CanUserAddRows="False"
HorizontalAlignment="Left">
</DataGrid>
</Grid>
Upvotes: 1
Reputation: 453
Can you wrap the datagrid itself in a border?
<Grid>
<Border BorderBrush="#CDCDCD" BorderThickness="0,0,0,1">
<DataGrid>
<DataGrid.Columns>
...
<DataGrid.Columns/>
<DataGrid/>
<Border/>
<Grid/>
Upvotes: 0