WPF Toolkit Datagrid - Custom Tabbing

拥有回忆 提交于 2019-12-22 04:11:29

问题


I have a WPF Toolkit DataGrid with 3 columns. Only the third column allows data entry - the first two are static (Text descriptions). Is it possible to control tabbing and navigation such that the tab and up-down-left-right buttons will ignore the first two columns and operate within the confines of the third?


回答1:


You can disable tabbing on the first two columns with the IsTabStop property. Unfortunately this isn't as easy to access as some of the other WPF controls so you have to set it via the CellStyle:

</dg:DataGridTextColumn>
    <dg:DataGridTextColumn.CellStyle>
        <Style TargetType="{x:Type dg:DataGridCell}">
            <Setter Property="IsTabStop" Value="False" />
        </Style>
    </dg:DataGridTextColumn.CellStyle>
</dg:DataGridTextColumn>



回答2:


This may not fully answer your question, but hopefully it will get you started. I ran into a bug with the WPF Toolkit DataGrid that inserted a garbage character when using the backspace key to clear the cell's contents. This led me to a CodePlex post about the bug, and the resulting method overrides (I subclassed both the grid and the column) allowed me to bypass the problem.

Here is the post that got me started: http://wpf.codeplex.com/WorkItem/View.aspx?WorkItemId=10246

I assume that you could trap the tab key and only pass it on if the user is in the third column?

Hope this helps - I am relatively new to WPF, so still learning the internals.



来源:https://stackoverflow.com/questions/858938/wpf-toolkit-datagrid-custom-tabbing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!