WPFにおけるGrid実装メッシュ,表スタイル汎用クラス
3535 ワード
///
/// Grid
///
///
public static void InsertFrameForGrid(Grid grid)
{
var rowcon = grid.RowDefinitions.Count;
var clcon = grid.ColumnDefinitions.Count;
for (var i = 0; i < rowcon + 1; i++)// border
{
var border = new Border
{
BorderBrush = new SolidColorBrush(Colors.SlateGray),
BorderThickness = i == rowcon ? new Thickness(0, 0, 0, 1) : new Thickness(0, 1, 0, 0)
};
Grid.SetRow(border, i);
Grid.SetColumnSpan(border, clcon);
grid.Children.Add(border);
}
for (var j = 0; j < clcon + 1; j++)// border
{
var border = new Border
{
BorderBrush = new SolidColorBrush(Colors.SlateGray),
BorderThickness = j == clcon ? new Thickness(0, 0, 1, 0) : new Thickness(1, 0, 0, 0)
};
Grid.SetColumn(border, j);
Grid.SetRowSpan(border, rowcon);
grid.Children.Add(border);
}
}
転載先:https://www.cnblogs.com/wortliu/p/5482275.html