本文整理汇总了C#中System.Windows.Controls.Grid.InvalidateArrange方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.InvalidateArrange方法的具体用法?C# Grid.InvalidateArrange怎么用?C# Grid.InvalidateArrange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Grid
的用法示例。
在下文中一共展示了Grid.InvalidateArrange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitGrid
private static void InitGrid(Grid grid, DtoTableViewModel vm)
{
if (vm != null && grid != null)
{
grid.RowDefinitions.Clear();
grid.ColumnDefinitions.Clear();
foreach (var row in vm.Rows)
{
grid.RowDefinitions.Add(new RowDefinition());
}
foreach (var col in vm.Columns)
{
grid.ColumnDefinitions.Add(new ColumnDefinition() { SharedSizeGroup = "col" + col.Column.ToString() });
}
grid.InvalidateArrange();
grid.UpdateLayout();
}
}
示例2: initialChildren
// Calculated content height
protected virtual void initialChildren()
{
double w = System.Windows.Application.Current.Host.Content.ActualWidth;
topShadow = GetTemplateChild("TopShadow") as Rectangle;
bottomShadow = GetTemplateChild("BottomShadow") as Rectangle;
contentView = GetTemplateChild("ContentView") as Grid;
buttonContainer = GetTemplateChild("ButtonContainer") as StackPanel;
curtain = GetTemplateChild("Curtain") as Rectangle;
// Add an optional title label
titleLabel = null;
if (title != null)
{
titleLabel = new TextBlock();
titleLabel.Text = title;
titleLabel.Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0xd9, 0xf3));
titleLabel.FontSize = 42;
titleLabel.HorizontalAlignment = HorizontalAlignment.Center;
titleLabel.TextWrapping = TextWrapping.Wrap;
titleLabel.TextAlignment = TextAlignment.Center;
titleLabel.Margin = new Thickness(0, 8, 0, 8);
titleLabel.SetValue(Grid.RowProperty, 0);
contentView.Children.Add(titleLabel);
}
// Add any custom content
if (contentElement != null)
{
contentElement.SetValue(Grid.RowProperty, 1);
contentView.Children.Add(contentElement);
contentView.InvalidateArrange();
contentView.UpdateLayout();
double measuredWidth = contentElement.ActualWidth + contentElement.Margin.Left + contentElement.Margin.Right;
double measuredHeight = 0;
if (titleLabel != null)
{
measuredHeight += titleLabel.ActualHeight;
}
double contentHeight = Math.Max(contentElement.ActualHeight, contentElement.Height);
if(!double.IsNaN(contentHeight))
measuredHeight += contentHeight + contentElement.Margin.Top + contentElement.Margin.Bottom;
else
measuredHeight += 240 + contentElement.Margin.Top + contentElement.Margin.Bottom;
expectedContentSize = new Size(measuredWidth, measuredHeight);
}
else
{
expectedContentSize = new Size(w, 240);
}
// Add custom buttons
if (buttonTitles.Count > 0)
{
foreach (string buttonTitle in buttonTitles)
{
var button = new Avarice.Controls.Button();
button.Content = buttonTitle;
button.Margin = new Thickness(20, 0, 20, 0);
button.HorizontalAlignment = HorizontalAlignment.Right;
buttonContainer.Children.Add(button);
button.Click += OnButtonClick;
}
}
else if(Buttons.Count > 0)
{
foreach (var button in Buttons)
{
button.Margin = new Thickness(20, 0, 20, 0);
button.HorizontalAlignment = HorizontalAlignment.Right;
buttonContainer.Children.Add(button);
button.Click += OnButtonClick;
}
}
}
示例3: RebuildGridChildren
private static void RebuildGridChildren(Grid grid)
{
int column = 0;
int row = 0;
var columnCount = GetColumns(grid);
for (int i = 0; i < grid.Children.Count; i++)
{
var child = grid.Children[i];
if (child == null) continue;
Grid.SetColumn(child, column);
Grid.SetRow(child, row);
column++;
if (column >= columnCount)
{
column = 0;
row++;
}
}
grid.InvalidateArrange();
grid.InvalidateVisual();
}