當前位置: 首頁>>代碼示例>>C#>>正文


C# Grid.WaitForNonZeroSizeAsync方法代碼示例

本文整理匯總了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();
        }
開發者ID:MSiccDev,項目名稱:WinRTXamlToolkit,代碼行數:48,代碼來源:DebugTreeViewTestView.xaml.cs


注:本文中的Windows.UI.Xaml.Controls.Grid.WaitForNonZeroSizeAsync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。