Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

WPF datagrid's cells contain a border on their left sides

My WPF DataGrid contains an extra item which can be highlighted when hovering the mouse over it.

Which exact property is used to enable/disable it?

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The following is a snippet of the XAML code used:

<DataGrid x:Name="DgMonitor" Grid.Row="0" Margin="10,10,10,5" Background="White" CanUserAddRows="False" RowHeight="34"
            AutoGenerateColumns="False" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent"
            GridLinesVisibility="All" HeadersVisibility="All" CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeColumns="False" CanUserResizeRows="False"
            VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" SelectionMode="Single" SelectionUnit="FullRow">
     <DataGrid.Columns>
        <DataGridTemplateColumn Width="*">
          <DataGridTemplateColumn.CellTemplate>
              <DataTemplate>
                 <Grid Margin="5,0,10,0" >
                    <Grid.ColumnDefinitions>
                       <ColumnDefinition Width="*"/>
                       <ColumnDefinition Width="Auto"/>
                       <ColumnDefinition Width="Auto"/>
                       <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Margin="0,0" VerticalAlignment="Center" TextWrapping="Wrap"/>
                    <Button Grid.Column="1" Width="20" Height="20" Margin="2"/>
                    <Button Grid.Column="2" Width="20" Height="20" Margin="2"/>
                    <Button Grid.Column="3" Width="20" Height="20" Margin="2"/>
                 </Grid>
              </DataTemplate>
           </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
       </DataGridTemplateColumn>
     </DataGrid.Columns>
  </DataGrid>

>Solution :

Update this…

<DataGrid x:Name="DgMonitor" Grid.Row="0" Margin="10,10,10,5" Background="White" CanUserAddRows="False" RowHeight="34"
            AutoGenerateColumns="False" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent"
            GridLinesVisibility="All" HeadersVisibility="All" CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeColumns="False" CanUserResizeRows="False"
            VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" SelectionMode="Single" SelectionUnit="FullRow">

…to include…

RowHeaderWidth="0"

And/or you may also wish to consider changing HeadersVisibility="All" to something more apt, such as HeadersVisibility="Column"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading