本文整理匯總了C#中Windows.UI.Xaml.Controls.Grid.WaitForNonZeroSizeAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# Grid.WaitForNonZeroSizeAsync方法的具體用法?C# Grid.WaitForNonZeroSizeAsync怎麽用?C# Grid.WaitForNonZeroSizeAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.UI.Xaml.Controls.Grid
的用法示例。
在下文中一共展示了Grid.WaitForNonZeroSizeAsync方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: InitializeTest
private async void InitializeTest()
{
_grids.Add(testPanel);
await this.WaitForLoadedAsync();
var random = new Random();
var colors = ColorExtensions.GetNamedColors();
for (int i = 0; i < 20; i++)
{
var panel = _grids[random.Next(0, _grids.Count)];
if (panel.ActualWidth - 10 <= 10 ||
panel.ActualHeight - 10 <= 10)
{
i--;
continue;
}
var border = new Border();
border.HorizontalAlignment = HorizontalAlignment.Left;
border.VerticalAlignment = VerticalAlignment.Top;
border.Width = random.Next((int)(panel.ActualWidth / 2), (int)(panel.ActualWidth - 10));
border.Height = random.Next((int)(panel.ActualHeight / 2), (int)(panel.ActualHeight - 10));
border.Margin =
new Thickness(
random.Next(0, (int)(panel.ActualWidth - border.Width) + 1),
random.Next(0, (int)(panel.ActualHeight - border.Height) + 1),
0,
0);
border.Background = new SolidColorBrush(colors[random.Next(colors.Count)]);
var childGrid = new Grid {VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch};
_grids.Add(childGrid);
border.Child = childGrid;
panel.Children.Add(border);
var tb =
new TextBlock
{
Text = string.Format("Panel {0}", i + 1),
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Top
};
childGrid.Children.Add(tb);
await childGrid.WaitForNonZeroSizeAsync();
}
DC.ShowVisualTree(_grids[random.Next(_grids.Count)]);
DC.Expand();
}