如何获取WPF数据网格中仅可见列的计数
如何获取WPF数据网格中仅可见列的计数。我使用计数来浏览数据网格中的列如何获取WPF数据网格中仅可见列的计数,wpf,c#-4.0,wpfdatagrid,Wpf,C# 4.0,Wpfdatagrid,如何获取WPF数据网格中仅可见列的计数。我使用计数来浏览数据网格中的列 if (getSelectedRow().IsEditing) { if (dataGrid.SelectedCells.Count != 0) { int columnDisplayIndex = dataGrid.CurrentC
if (getSelectedRow().IsEditing)
{
if (dataGrid.SelectedCells.Count != 0)
{
int columnDisplayIndex = dataGrid.CurrentCell.Column.DisplayIndex + 1;
if (columnDisplayIndex <= dataGrid.Columns.Count)
{
if (columnDisplayIndex == dataGrid.Columns.Count)
{
row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
nextColumn = dataGrid.ColumnFromDisplayIndex(nextCol(1) - 1);
dataGrid.CurrentCell = new DataGridCellInfo(dataGrid.SelectedItem, nextColumn);
}
else
{
e.Handled = true;
nextColumn = dataGrid.ColumnFromDisplayIndex(nextCol(columnDisplayIndex));
dataGrid.CurrentCell = new DataGridCellInfo(dataGrid.SelectedItem, nextColumn);
}
}
}
if (isNotComboBox())
{
dataGrid.CommitEdit();
}
}
if(getSelectedRow().IsEditing)
{
if(dataGrid.SelectedCells.Count!=0)
{
int columnDisplayIndex=dataGrid.CurrentCell.Column.DisplayIndex+1;
如果(columnDisplayIndex)可能是一个愚蠢的问题,因为我不喜欢WPF,但是否有一个“可见的”这些列上的属性?给我们看一点代码,告诉我们你试过什么!@sexta:这里代码是不相关的,因为我没有得到datagrid的可见列数,所以我想稍微更正一下代码结构。但是这对以后的更改不安全,所以我必须得到一个正确的解决方案。你不想得到列列表并检查y是否可见?dataGrid.Columns.Where(x=>x.Visibility==Visibility.visible)?什么是未来不安全?是否担心Visibility属性可能消失?请格式化代码,这样我们就不必向右滚动。