-
遍历WPF DataGrid单元格
- using System.Windows.Controls;
- using System.Windows.Controls.Primitives;
- using System.Windows.Media;
-
- namespace Splash.WPF
- {
- public static class DataGridPlus
- {
-
-
-
-
-
-
-
- public static DataGridCell GetCell(this DataGrid dataGrid, int rowIndex, int columnIndex)
- {
- DataGridRow rowContainer = dataGrid.GetRow(rowIndex);
- if (rowContainer != null)
- {
- DataGridCellsPresenter presenter = GetVisualChild<DataGridCellsPresenter>(rowContainer);
- DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);
- if (cell == null)
- {
- dataGrid.ScrollIntoView(rowContainer, dataGrid.Columns[columnIndex]);
- cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(columnIndex);
- }
- return cell;
- }
- return null;
- }
-
-
-
-
-
-
-
- public static DataGridRow GetRow(this DataGrid dataGrid, int rowIndex)
- {
- DataGridRow rowContainer = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(rowIndex);
- if (rowContainer == null)
- {
- dataGrid.UpdateLayout();
- dataGrid.ScrollIntoView(dataGrid.Items[rowIndex]);
- rowContainer = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(rowIndex);
- }
- return rowContainer;
- }
-
-
-
-
-
-
-
- public static T GetVisualChild<T>(Visual parent) where T : Visual
- {
- T child = default(T);
- int numVisuals = VisualTreeHelper.GetChildrenCount(parent);
- for (int i = 0; i < numVisuals; i++)
- {
- Visual v = (Visual)VisualTreeHelper.GetChild(parent, i);
- child = v as T;
- if (child == null)
- {
- child = GetVisualChild<T>(v);
- }
- if (child != null)
- {
- break;
- }
- }
- return child;
- }
- }
- }
-
相关阅读:
C#编程思路
将字符串类型字段转为map类型字段,使用str_to_map()函数
写hive脚本时,如果hive的过滤条件比较多。可以把过滤条件放到一个参数里。然后把参数放到过滤条件处。这样以后只需要改参数就可以了
linux中. 路径/文件
inner join ,left join 会导致数据发散
如何批量按分区插入数据
hive表添加字段后,查不出数据是咋回事?
linux中$0的含义
linux中的$#含义
linux的语法
-
原文地址:https://www.cnblogs.com/HelloXZ/p/3799582.html
Copyright © 2020-2023
润新知