本文整理汇总了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);
}
}
示例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);
}
}
}