Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I have designed one datagrid with header color as blue,background as white and with a vertical scroll bar.
but the problem is when i m enabling the scroll bar properly to visible, that time at the right side top corner one space is coming due to that scroll bar.the header is not covering the total area..

please tell me how to cover that gap.
below is my xaml code:

HTML
<DataGrid AlternatingRowBackground="#64BDC6D7" AlternationCount="2" AreRowDetailsFrozen="False" AutoGenerateColumns="False" Background="White" BorderBrush="Navy" CanUserAddRows="True" Canvas.Left="15" Canvas.Top="203" ClipboardCopyMode="IncludeHeader" ColumnHeaderHeight="20" EnableColumnVirtualization="True" FontSize="10" Foreground="White" GridLinesVisibility="All" HeadersVisibility="All" Height="107" HorizontalGridLinesBrush="#64BDC6D7" Name="DataGrid1" OverridesDefaultStyle="False" Rowremoved="White" RowDetailsVisibilityMode="Visible" SelectionMode="Extended" SelectionUnit="Cell" SnapsToDevicePixels="False" UseLayoutRounding="True" Width="592" VerticalGridLinesBrush="Navy" VerticalScrollBarVisibility="Visible" RowHeaderWidth="100" CanUserResizeRows="False">
             <DataGrid.Columns>
                 <DataGridTextColumn Header="" Width="20
                                     " />
                 <DataGridTextColumn Header="Billdate" Width="50" />
                 <DataGridTextColumn Header="Bill No" Width="50" />
                 <DataGridTextColumn Header="Bill Amount" Width="70" />
                 <DataGridTextColumn Header="Due days" Width="60" />
                 <DataGridTextColumn Header="Due Date" Width="50" />
             </DataGrid.Columns>
             <DataGrid.Resources>
                 <Style TargetType="{x:Type DataGridColumnHeader}">
                     <Setter Property="Control.Background" Value="#FF35496A" />
                 </Style>
             </DataGrid.Resources>
         </DataGrid>
Posted

1 solution

That's the expected behavior. The headers are the widths of the columns they sit over. If you want the header wider, you'll put the contents of the column under the vertical scrollbar and on top of that, since the entire contents are no longer 100% visible, you'll get a horizontal scroll bar acrossed the bottom of the grid.

Is it really that neccessary to fill the width of the header?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900