/// <summary>
/// 获取控件
/// </summary>
/// <param name="control_name">控件名</param>
/// <param name="row">行</param>
/// <param name="col">列</param>
private void setStar(string control_name, int row, int col = 4)
{
DataGridTemplateColumn templeColumn = grd_fan.Columns[col] as DataGridTemplateColumn;
FrameworkElement s = grd_fan.Columns[col].GetCellContent(grd_fan.Items[row]);
Button tbOper = templeColumn.CellTemplate.FindName(control_name, s) as Button;
tbOper.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffc400"));
}
wpf 获取datagrid 中指定行列的DataGridTemplateColumn中的控件
最新推荐文章于 2023-07-04 21:07:15 发布
这段代码是一个私有方法,用于根据控件名、行数和列数在DataGrid中获取特定控件,并设置其背景颜色为#ffc400。它首先通过列索引获取DataGridTemplateColumn,然后找到指定的FrameworkElement,最后定位到名为'control_name'的Button并改变其背景色。
1211

被折叠的 条评论
为什么被折叠?



