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


C# ContentControl.SetValue方法代碼示例

本文整理匯總了C#中Windows.UI.Xaml.Controls.ContentControl.SetValue方法的典型用法代碼示例。如果您正苦於以下問題:C# ContentControl.SetValue方法的具體用法?C# ContentControl.SetValue怎麽用?C# ContentControl.SetValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.UI.Xaml.Controls.ContentControl的用法示例。


在下文中一共展示了ContentControl.SetValue方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SquareOfSquares

        public SquareOfSquares()
        {
            this.InitializeComponent();

            Root.RowDefinitions.Clear();
            Root.RowDefinitions.Clear();

            for (int i = 0; i < 112; i++)
            {
                Root.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
                Root.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
            }

            foreach (InnerSquare square in GetSquares())
            {
                var ctl = new ContentControl();
                ctl.SetValue(Grid.RowProperty, square.Position.Y);
                ctl.SetValue(Grid.ColumnProperty, square.Position.X);
                ctl.SetValue(Grid.ColumnSpanProperty, square.Side);
                ctl.SetValue(Grid.RowSpanProperty, square.Side);
                Root.Children.Add(ctl);
                Squares.Add(ctl);
            }
        }
開發者ID:XamlBrewer,項目名稱:UWP-Composition-Radial-Gauge,代碼行數:24,代碼來源:SquareOfSquares.xaml.cs

示例2: RebuildTable

 private void RebuildTable()
 {
     Children.Clear();
     if (ItemsSource == null || !(ItemsSource is IEnumerable))
         return;
     var list = (ItemsSource as IEnumerable).OfType<object>().ToList();
     int count = list.Count;
     int rows = currentRowCount;
     int cols = currentColumnCount;
     int itemSpace = rows * cols;
     bool hasLiveTile = false;
     if (count > itemSpace)
     {
         LiveTile tile = new LiveTile()
         {
             ItemsSource = ItemsSource,
             ItemTemplate = LiveTileItemTemplate,
             Margin = new Thickness(0, 0, 20, 20)
         };
         tile.SetValue(Callisto.Effects.Tilt.IsTiltEnabledProperty, true);
         Children.Add(tile);
         hasLiveTile = true;
         tile.Tapped += livetile_Tapped;
     }
     int i = 0;
     for (int c = 0; c < cols; c++)
     {
         for (int r = 0; r < rows; r++)
         {
             if (i >= list.Count)
                 break;
             if (hasLiveTile && c < 2 && r < 2)
                 continue;
             ContentControl ctrl = new ContentControl()
             {
                 Content = list[i++],
                 ContentTemplate = ItemTemplate,
                 Margin = new Thickness(0, 0, 20, 20),
                 HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch,
                 VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch,
                 HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch,
                 VerticalContentAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch
             };
             //ctrl.Transitions = new Windows.UI.Xaml.Media.Animation.TransitionCollection();
             //ctrl.Transitions.Add(new Windows.UI.Xaml.Media.Animation.AddDeleteThemeTransition());
             //ctrl.Transitions.Add(new Windows.UI.Xaml.Media.Animation.EntranceThemeTransition());
             ctrl.SetValue(Callisto.Effects.Tilt.IsTiltEnabledProperty, true);
             if (r == rows - 1 && c == Math.Min(cols, MaxColumnCount) - 1 &&
                 count > rows * cols) // last item
             {
                 ctrl.ContentTemplate = MoreTemplate;
                 ctrl.Tapped += moreTile_Tapped;
             }
             else
             {
                 ctrl.Tapped += ctrl_Tapped;
             }
             Children.Add(ctrl);
         }
     }
 }
開發者ID:smarteatsmarties,項目名稱:arcgis-portalviewer-dotnet,代碼行數:61,代碼來源:GalleryPreviewControl.cs


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