NoPyGod
NoPyGod

Reputation: 5067

Prevent cell level tab stops, but still allow rows to have tabstops in a WPF DataGrid

I wish to prevent tabstops on individual cells, but allow row level tabstops

I thought I could just use CellStyle to disable IsTabStop on all cells

<DataGrid.CellStyle>
    <Style TargetType="DataGridCell">
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="IsTabStop" Value="false"/>
    </Style>
</DataGrid.CellStyle>

But this prevents rows from having tabstops too

So I thought I should enable tabstops on rows using RowStyle

<DataGrid.RowStyle>
    <Style TargetType="DataGridRow">
        <Setter Property="IsTabStop" Value="true"/>
    </Style>
</DataGrid.RowStyle>

But this does not work either

Anybody got any ideas?

Upvotes: 3

Views: 3182

Answers (1)

NoPyGod
NoPyGod

Reputation: 5067

My solution was this -

Change IsTabStop to false for all DataGridCell columns

Change IsTabStop to true for my main column which is a DataGridTemplateColumn

<DataGrid.CellStyle>
    <Style TargetType="DataGridCell">
        <Setter Property="IsTabStop" Value="false"/>
    </Style>
</DataGrid.CellStyle>


<DataGrid.Columns>

    <DataGridTemplateColumn Header="File name" Width="435">

        <DataGridTemplateColumn.CellStyle>
            <Style TargetType="DataGridCell">
                <Setter Property="IsTabStop" Value="true"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            </Style>
        </DataGridTemplateColumn.CellStyle>

    ...........

By including this line I am able to disable the dotted line square border

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

edit*

Nevermind, this is too much trouble. I think it makes more sense for me to use a listview at this point.

Upvotes: 7

Related Questions