摆脱WPF数据网格中的双Tabing

时间:2017-06-26 06:45:01

标签: wpf datagrid tabindex

我的数据网格的最后一列是只读的,因为我将可聚焦属性设置为错误,因此应该完全忽略该标签。数据网格不是自定义的,只是它的样式。

First tab

我无法让Tab忽略最后两列。我想从第8列跳到下一行的开头。相反,在进入下一行之前,我必须在最后两列中进行选项卡。

<Style x:Key="DataGridCellFocusVisualStyle">
    <Setter Property="Control.Template">
        <Setter.Value>
            <ControlTemplate>
                <Rectangle  StrokeThickness="2"  
                            Stroke="{StaticResource DarkGrayBrush}"   
                            SnapsToDevicePixels="true"
                            Margin="-5 0 0 0"/>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}">
    <Setter Property="BorderBrush" Value="{StaticResource DarkGrayBrush}" />
    <Setter Property="BorderThickness" Value="0 0 1 0" />
    <Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type DataGridCell}">
                <ContentControl Margin="5 0 0 0" Content="{TemplateBinding Content}" 
                                FocusVisualStyle="{StaticResource DataGridCellFocusVisualStyle}"/>

            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <Style.Triggers>
        <Trigger Property="IsSelected" Value="True" >
            <Setter Property="Foreground" Value="{StaticResource BlackBrush}"/>
            <Setter Property="Background" Value="{StaticResource WhiteBrush}"/>
        </Trigger>
        <Trigger Property="IsReadOnly" Value="True">
            <Setter Property="IsTabStop" Value="False"/>
        </Trigger>
    </Style.Triggers>
</Style>

这是我要跳过的专栏。

Cell样式基于我们在XAML顶部的 DataGridCellStyle 中看到的CellStyle。

 <Style x:Key="CalculationNumericColumnCellStyle"
       BasedOn="{StaticResource LeschacoDataGridCellStyle}"
       TargetType="{x:Type DataGridCell}">
    <Setter Property="TextBlock.TextAlignment" Value="Right" />
</Style>

2 个答案:

答案 0 :(得分:2)

尝试以下样式,它将跳过您放置IsReadOnly =“True”的所有列。

<Style TargetType="{x:Type DataGridCell}">
    <Style.Triggers>
        <Trigger Property="IsReadOnly" Value="true">
            <Setter Property="IsTabStop" Value="False"/>
        </Trigger>
    </Style.Triggers>
</Style>

答案 1 :(得分:0)

我又回答了自己的问题。我看到当我将模板应用于数据网格的这一部分时,数据网格单元似乎被 TabManager 视为两个可视树中的控件。所以数据网格单元格焦点视觉风格虚线矩形焦点视觉风格 < strong>模板是连续矩形。因此,这里学到的经验教训是,除非绝对必须,否则不应将模板应用于控件。如果有人感兴趣的话,那就是数据网格单元的新XAML实现。

npm install
? Running command - failed!
[ERROR] An error occurred while running npm install (exit code 1):

        npm ERR! git clone
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-github-com-resi
n-io-bonjour-git-d75da30c
        C:\Users\Dell\AppData\Local\Temp\npm-6132-a1e44593\git-cache-8f1516dd\31
d080cee1d8a4b74e03818aaee14da8062f0ea1:
        Cloning into
        'C:\Users\Dell\AppData\Local\Temp\npm-6132-a1e44593\git-cache-8f1516dd\3
1d080cee1d8a4b74e03818aaee14da8062f0ea1'...
        npm ERR! git clone
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-github-com-resi
n-io-bonjour-git-d75da30c
        C:\Users\Dell\AppData\Local\Temp\npm-6132-a1e44593\git-cache-8f1516dd\31
d080cee1d8a4b74e03818aaee14da8062f0ea1:
        error: cannot spawn sh: No such file or directory
        npm ERR! git clone
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-github-com-resi
n-io-bonjour-git-d75da30c
        C:\Users\Dell\AppData\Local\Temp\npm-6132-a1e44593\git-cache-8f1516dd\31
d080cee1d8a4b74e03818aaee14da8062f0ea1:
        fatal: unable to fork
        npm ERR! git clone
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-github-com-resi
n-io-bonjour-git-d75da30c
        C:\Users\Dell\AppData\Local\Temp\npm-6132-a1e44593\git-cache-8f1516dd\31
d080cee1d8a4b74e03818aaee14da8062f0ea1:

        npm ERR! git clone
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-https-github-co
m-resin-io-bonjour-git-3f9321aa
        C:\Users\Dell\AppData\Local\Temp\npm-6132-a1e44593\git-cache-534cbd12\31
d080cee1d8a4b74e03818aaee14da8062f0ea1:
        Cloning into
        'C:\Users\Dell\AppData\Local\Temp\npm-6132-a1e44593\git-cache-534cbd12\3
1d080cee1d8a4b74e03818aaee14da8062f0ea1'...
        npm ERR! git clone
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-https-github-co
m-resin-io-bonjour-git-3f9321aa
        C:\Users\Dell\AppData\Local\Temp\npm-6132-a1e44593\git-cache-534cbd12\31
d080cee1d8a4b74e03818aaee14da8062f0ea1:
        error: cannot spawn sh: No such file or directory
        npm ERR! git clone
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-https-github-co
m-resin-io-bonjour-git-3f9321aa
        C:\Users\Dell\AppData\Local\Temp\npm-6132-a1e44593\git-cache-534cbd12\31
d080cee1d8a4b74e03818aaee14da8062f0ea1:
        fatal: unable to fork
        npm ERR! git clone
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-https-github-co
m-resin-io-bonjour-git-3f9321aa
        C:\Users\Dell\AppData\Local\Temp\npm-6132-a1e44593\git-cache-534cbd12\31
d080cee1d8a4b74e03818aaee14da8062f0ea1:

        npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true
        config --get remote.origin.url
        npm WARN addRemoteGit
        npm WARN addRemoteGit     at ChildProcess.exithandler
        (child_process.js:205:12)
        npm WARN addRemoteGit     at emitTwo (events.js:106:13)
        npm WARN addRemoteGit     at ChildProcess.emit (events.js:194:7)
        npm WARN addRemoteGit     at maybeClose
        (internal/child_process.js:899:16)
        npm WARN addRemoteGit     at Process.ChildProcess._handle.onexit
        (internal/child_process.js:226:5)
        npm WARN addRemoteGit  resin-io/bonjour resetting remote
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-github-com-resi
n-io-bonjour-git-41f67eef
        because of error: { Error: Command failed: git -c core.longpaths=true
        config --get remote.origin.url
        npm WARN addRemoteGit
        npm WARN addRemoteGit     at ChildProcess.exithandler
        (child_process.js:205:12)
        npm WARN addRemoteGit     at emitTwo (events.js:106:13)
        npm WARN addRemoteGit     at ChildProcess.emit (events.js:194:7)
        npm WARN addRemoteGit     at maybeClose
        (internal/child_process.js:899:16)
        npm WARN addRemoteGit     at Process.ChildProcess._handle.onexit
        (internal/child_process.js:226:5)
        npm WARN addRemoteGit   killed: false,
        npm WARN addRemoteGit   code: 1,
        npm WARN addRemoteGit   signal: null,
        npm WARN addRemoteGit   cmd: 'git -c core.longpaths=true config --get
        remote.origin.url' }
        npm ERR! git clone
        --template=C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\_templat
es
        --mirror git@github.com:resin-io/bonjour.git
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-github-com-resi
n-io-bonjour-git-41f67eef:
        Cloning into bare repository
        'C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-github-com-res
in-io-bonjour-git-41f67eef'...
        npm ERR! git clone
        --template=C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\_templat
es
        --mirror git@github.com:resin-io/bonjour.git
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-github-com-resi
n-io-bonjour-git-41f67eef:
        error: cannot spawn ssh: No such file or directory
        npm ERR! git clone
        --template=C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\_templat
es
        --mirror git@github.com:resin-io/bonjour.git
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-github-com-resi
n-io-bonjour-git-41f67eef:
        fatal: unable to fork
        npm ERR! Windows_NT 6.1.7601
        npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program
        Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
        npm ERR! node v7.10.0
        npm ERR! npm  v4.2.0
        npm ERR! code 128

        npm ERR! Command failed: git -c core.longpaths=true clone
        --template=C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\_templat
es
        --mirror git@github.com:resin-io/bonjour.git
        C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-github-com-resi
n-io-bonjour-git-41f67eef
        npm ERR! Cloning into bare repository
        'C:\Users\Dell\AppData\Roaming\npm-cache\_git-remotes\git-github-com-res
in-io-bonjour-git-41f67eef'...
        npm ERR! error: cannot spawn ssh: No such file or directory
        npm ERR! fatal: unable to fork
        npm ERR!
        npm ERR!
        npm ERR! If you need help, you may report this error at:
        npm ERR!     <https://github.com/npm/npm/issues>

        npm ERR! Please include the following file with any support request:
        npm ERR!
        C:\Users\Dell\AppData\Roaming\npm-cache\_logs\2017-06-28T05_13_49_485Z-d
ebug.log