-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from CommunityToolkit/llama/canvaslayout-rebase
Add Initial CanvasLayout component on top of initial project to aid testing/setup
- Loading branch information
Showing
8 changed files
with
239 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Labs/CanvasLayout/samples/CanvasLayout.Sample/SampleThree/SamplePage3.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<Page | ||
x:Class="CanvasLayout.Sample.SampleThree.SamplePage3" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="using:CanvasLayout.Sample.SampleThree" | ||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" | ||
xmlns:labs="using:CommunityToolkit.Labs.Uwp" | ||
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" | ||
mc:Ignorable="d"> | ||
|
||
<ScrollViewer | ||
HorizontalScrollMode="Auto" | ||
HorizontalScrollBarVisibility="Auto" | ||
VerticalScrollMode="Auto" | ||
VerticalScrollBarVisibility="Auto"> | ||
<muxc:ItemsRepeater ItemsSource="{x:Bind Items}"> | ||
<muxc:ItemsRepeater.Layout> | ||
<labs:CanvasLayout/> | ||
</muxc:ItemsRepeater.Layout> | ||
<muxc:ItemsRepeater.ItemTemplate> | ||
<DataTemplate x:DataType="local:CanvasItem"> | ||
<Border Width="{x:Bind Width}" Height="{x:Bind Height}" | ||
CornerRadius="9999" | ||
Background="Red" | ||
BorderBrush="White" BorderThickness="2"> | ||
<TextBlock Text="{x:Bind Text}" | ||
Foreground="White" | ||
FontSize="24" | ||
FontWeight="Bold" | ||
HorizontalAlignment="Center" | ||
win:TextLineBounds="Tight" | ||
VerticalAlignment="Center"/> | ||
</Border> | ||
</DataTemplate> | ||
</muxc:ItemsRepeater.ItemTemplate> | ||
</muxc:ItemsRepeater> | ||
</ScrollViewer> | ||
</Page> |
65 changes: 65 additions & 0 deletions
65
Labs/CanvasLayout/samples/CanvasLayout.Sample/SampleThree/SamplePage3.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// 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. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using CommunityToolkit.Labs.Core.SourceGenerators; | ||
using CommunityToolkit.Labs.Core.SourceGenerators.Attributes; | ||
using CommunityToolkit.Labs.Uwp; | ||
|
||
#if !WINAPPSDK | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
#else | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using Microsoft.UI.Xaml.Data; | ||
using Microsoft.UI.Xaml.Input; | ||
using Microsoft.UI.Xaml.Media; | ||
using Microsoft.UI.Xaml.Navigation; | ||
#endif | ||
|
||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 | ||
|
||
namespace CanvasLayout.Sample.SampleThree | ||
{ | ||
/// <summary> | ||
/// An empty page that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
[ToolkitSample(id: nameof(SamplePage3), "Canvas Layout", ToolkitSampleCategory.Controls, ToolkitSampleSubcategory.Layout, description: "A canvas-like VirtualizingLayout for use in an ItemsRepeater")] | ||
public sealed partial class SamplePage3 : Page | ||
{ | ||
public ObservableCollection<CanvasItem> Items = new() | ||
{ | ||
new() { Left = 100, Top = 50, Width = 100, Height = 100, Text = "Item 1" }, | ||
new() { Left = 400, Top = 250, Width = 200, Height = 200, Text = "Item 2" }, | ||
new() { Left = 200, Top = 500, Width = 100, Height = 100, Text = "Item 3" }, | ||
new() { Left = 1200, Top = 2500, Width = 100, Height = 100, Text = "Item 4" }, | ||
new() { Left = 2200, Top = 1500, Width = 100, Height = 100, Text = "Item 5" }, | ||
new() { Left = 1200, Top = 3500, Width = 100, Height = 100, Text = "Item 6" }, | ||
}; | ||
|
||
public SamplePage3() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} | ||
|
||
public class CanvasItem : CanvasLayoutItem | ||
{ | ||
public string Text { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters