Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions components/Primitives/samples/WrapLayoutSample.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Page x:Class="PrimitivesExperiment.Samples.WrapLayoutSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand All @@ -10,31 +10,30 @@
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">
<Page.Resources>
<DataTemplate x:Key="WrapTemplate">
<Border Width="{Binding Width}"
<DataTemplate x:Key="WrapTemplate"
x:DataType="local:ColorItem">
<Border Width="{x:Bind Width}"
Height="48"
CornerRadius="{StaticResource ControlCornerRadius}">
<Border.Background>
<SolidColorBrush Color="{Binding Color}" />
<SolidColorBrush Color="{x:Bind Color}" />
</Border.Background>
<TextBlock Margin="6,4,4,4"
FontSize="16"
Text="{Binding Index}" />
Text="{x:Bind Index}" />
</Border>
</DataTemplate>
</Page.Resources>

<Grid>
<ScrollViewer x:Name="WrapScrollParent">
<muxc:ItemsRepeater x:Name="WrapRepeater"
ItemTemplate="{StaticResource WrapTemplate}"
ItemsSource="{x:Bind ColorsCollection, Mode=OneWay}">
<muxc:ItemsRepeater.Layout>
<controls:WrapLayout x:Name="Wrap"
HorizontalSpacing="{x:Bind HorizontalSpacing, Mode=OneWay}"
VerticalSpacing="{x:Bind VerticalSpacing, Mode=OneWay}" />
</muxc:ItemsRepeater.Layout>
</muxc:ItemsRepeater>
</ScrollViewer>
<muxc:ItemsRepeater x:Name="WrapRepeater"
ItemTemplate="{StaticResource WrapTemplate}"
ItemsSource="{x:Bind ColorsCollection, Mode=OneWay}">
<muxc:ItemsRepeater.Layout>
<controls:WrapLayout x:Name="Wrap"
HorizontalSpacing="{x:Bind HorizontalSpacing, Mode=OneWay}"
VerticalSpacing="{x:Bind VerticalSpacing, Mode=OneWay}" />
</muxc:ItemsRepeater.Layout>
</muxc:ItemsRepeater>
</Grid>
</Page>
8 changes: 7 additions & 1 deletion components/Primitives/samples/WrapLayoutSample.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ public WrapLayoutSample()
random = new Random(DateTime.Now.Millisecond);
for (int i = 0; i < random.Next(1000, 5000); i++)
{
var item = new ColorItem { Index = i, Width = random.Next(50, 250), Height = random.Next(50, 250), Color = Color.FromArgb(255, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255)) };
var item = new ColorItem
{
Index = i,
Width = random.Next(50, 250),
Height = random.Next(50, 250),
Color = Color.FromArgb(255, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))
};
ColorsCollection.Add(item);
}
}
Expand Down
Loading