How to extend the selected cell border over the entire row

Nov 10, 2008 at 2:23 PM
Hi,

I'm trying to get rid of this small cell border from the selected cell but I can't seem to find the property to do so. I would much rather have the cell's border when selected be placed instead on the entire row. Is there a way?

here is the markup for the grid:
        <toolkit:DataGrid Name="errorGrid" Grid.Row="1" AutoGenerateColumns="True"
                          GridLinesVisibility="Horizontal" CanUserAddRows="False" CanUserDeleteRows="False"
                          CanUserResizeRows="False" ColumnWidth="Auto" ColumnHeaderHeight="30"
                          RowHeight="21" HorizontalGridLinesBrush="DarkGray" RowHeaderWidth="0"
                          SelectionUnit="FullRow" HorizontalScrollBarVisibility="Auto" SelectionMode="Extended"
                          AlternatingRowBackground="Gainsboro" AutoGeneratedColumns="OnGridAutoGeneratedColumns">
            <toolkit:DataGrid.Columns>
                <toolkit:DataGridTemplateColumn Header="" Width="16" CanUserResize="False" CanUserReorder="False">
                    <toolkit:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="{Binding Path=Status, Converter={StaticResource statusConverter}, Mode=OneWay}" />
                        </DataTemplate>
                    </toolkit:DataGridTemplateColumn.CellTemplate>
                </toolkit:DataGridTemplateColumn>
            </toolkit:DataGrid.Columns>
        </toolkit:DataGrid>

i'll include a screenshot in a sec...

thanks!
sean

Nov 10, 2008 at 2:30 PM
Edited Nov 10, 2008 at 2:31 PM
here's the screenshot:
Screenshot

sean
Coordinator
Nov 10, 2008 at 6:16 PM
That is the doing of the DataGridCell's style.  When it is selected it updates the border.  You can remove it by overriding the style.  If you want something like that on the entire row, you can follow a similar pattern of the DataGridCell's style for the IsSelected trigger on the DataGridRow.
Mar 5, 2009 at 10:55 PM
The little border around the cell is still there even when you override the DataGridRow. Surely there is  a way to remove it.
Mar 5, 2009 at 11:20 PM
Here's how it works for me:

    <Style x:Key="DataGridRowStyle" TargetType="{x:Type dg:DataGridRow}">
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="BorderBrush" Value="Black"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="dg:DataGridCell">
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="BorderThickness" Value="0"/>
            </Trigger>
        </Style.Triggers>
    </Style>
Mar 5, 2009 at 11:33 PM
Hmm doesn't help me

 i have

 <Style TargetType="{x:Type wpfToolkit:DataGridRow}">
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Background" Value="#BFF0FF" />
                                </Trigger>
                                <Trigger Property="IsSelected" Value="True">
                                    <Setter Property="BorderThickness" Value="1"/>
                                    <Setter Property="BorderBrush" Value="Black"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>

                        <Style TargetType="{x:Type wpfToolkit:DataGridCell}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding LimitedDistributionIndicator}" Value="True">
                                    <Setter Property="BorderBrush" Value="{StaticResource DataGrid_Style0_LD}" />
                                    <Setter Property="BorderThickness" Value="0,2,0,2" />
                                </DataTrigger>
                                <Trigger Property="IsSelected" Value="True">
                                    <Setter Property="BorderThickness" Value="0"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>



see here -> http://www.filejumbo.com/Download/51BF028DC03839F9


Mar 5, 2009 at 11:54 PM
So you mean the border when tabbing through the fields, not the selection border? Then i have no idea. :( But i'm sure there is some way to restyle that thing, too.
Mar 6, 2009 at 12:04 AM
Yeah, i don't want any border inside the cell, frustrating !
Mar 6, 2009 at 8:06 AM
Try this in the DataGridCell's Style: 

<Setter Property="FocusVisualStyle" Value="{x:Null}"/>

Mar 11, 2009 at 12:43 AM
Nope :(

Still get the border around the cell.

<Style x:Key="CellStyle" TargetType="{x:Type wpfToolkit:DataGridCell}">
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
</Style>

 <wpfToolkit:DataGrid CellStyle="{StaticResource CellStyle}">




Mar 11, 2009 at 2:04 AM
Got it.

<Style x:Key="CellStyle" TargetType="{x:Type wpfToolkit:DataGridCell}">
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
</Style>
Nov 5, 2010 at 7:13 PM

Sorry to revive such an old thread, but...

Don't implement the above code if you want to use dataGrid.SelectedItem, or dataGrid.SelectedValue, or dataGrid.CurrentItem, because they won't work if the component isn't focusable.

:(