<!-- 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. --><Pagex:Class="LayoutTransformControlExperiment.Samples.LayoutTransformControlSample"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:controls="using:CommunityToolkit.WinUI.Controls"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:local="using:LayoutTransformControlExperiment.Samples"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d"><GridColumnSpacing="24"RowSpacing="24"><Grid.Resources><Stylex:Key="BorderCardStyle"TargetType="Border"><SetterProperty="Background"Value="{ThemeResource CardBackgroundFillColorDefaultBrush}" /><SetterProperty="BorderBrush"Value="{ThemeResource CardStrokeColorDefaultBrush}" /><SetterProperty="BorderThickness"Value="1" /><SetterProperty="Padding"Value="12" /><SetterProperty="CornerRadius"Value="{StaticResource ControlCornerRadius}" /></Style></Grid.Resources><Grid.RowDefinitions><RowDefinition /><RowDefinition /></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition /><ColumnDefinition /></Grid.ColumnDefinitions><!-- Layout Transform Fixed Size --><controls:LayoutTransformControl><controls:LayoutTransformControl.Transform><TransformGroup><RotateTransformAngle="{x:Bind Angle, Mode=OneWay}" /><ScaleTransformScaleX="{x:Bind CustomScaleX, Mode=OneWay}"ScaleY="{x:Bind CustomScaleY, Mode=OneWay}" /><SkewTransformAngleX="{x:Bind SkewX, Mode=OneWay}"AngleY="{x:Bind SkewY, Mode=OneWay}" /></TransformGroup></controls:LayoutTransformControl.Transform><BorderWidth="200"Height="50"Style="{StaticResource BorderCardStyle}"><TextBlockText="Layout Fixed Size." /></Border></controls:LayoutTransformControl><!-- Layout Transform Full Size --><controls:LayoutTransformControlGrid.Column="1"><controls:LayoutTransformControl.Transform><TransformGroup><RotateTransformAngle="{x:Bind Angle, Mode=OneWay}" /><ScaleTransformScaleX="{x:Bind CustomScaleX, Mode=OneWay}"ScaleY="{x:Bind CustomScaleY, Mode=OneWay}" /><SkewTransformAngleX="{x:Bind SkewX, Mode=OneWay}"AngleY="{x:Bind SkewY, Mode=OneWay}" /></TransformGroup></controls:LayoutTransformControl.Transform><BorderStyle="{StaticResource BorderCardStyle}"><TextBlockText="Layout Full Frame." /></Border></controls:LayoutTransformControl><!-- Render Transform Fixed Size --><BorderGrid.Row="1"Width="200"Height="50"RenderTransformOrigin="0.5,0.5"Style="{StaticResource BorderCardStyle}"><Border.RenderTransform><TransformGroup><RotateTransformAngle="{x:Bind Angle, Mode=OneWay}" /><ScaleTransformScaleX="{x:Bind CustomScaleX, Mode=OneWay}"ScaleY="{x:Bind CustomScaleY, Mode=OneWay}" /><SkewTransformAngleX="{x:Bind SkewX, Mode=OneWay}"AngleY="{x:Bind SkewY, Mode=OneWay}" /></TransformGroup></Border.RenderTransform><TextBlockText="Render Fixed Size." /></Border><!-- Render Transform Full Size --><BorderGrid.Row="1"Grid.Column="1"RenderTransformOrigin="0.5,0.5"Style="{StaticResource BorderCardStyle}"><Border.RenderTransform><TransformGroup><RotateTransformAngle="{x:Bind Angle, Mode=OneWay}" /><ScaleTransformScaleX="{x:Bind CustomScaleX, Mode=OneWay}"ScaleY="{x:Bind CustomScaleY, Mode=OneWay}" /><SkewTransformAngleX="{x:Bind SkewX, Mode=OneWay}"AngleY="{x:Bind SkewY, Mode=OneWay}" /></TransformGroup></Border.RenderTransform><TextBlockText="Render Full Frame." /></Border></Grid></Page>
C#
// 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 CommunityToolkit.WinUI.Controls;
namespaceLayoutTransformControlExperiment.Samples;
///<summary>/// An example sample page of a custom control inheriting from Panel.///</summary>
[ToolkitSampleNumericOption("Angle", 0, -180.0, 180.0, 1, false, Title = "Angle")]
[ToolkitSampleNumericOption("CustomScaleX", 1, 0.0, 5.0, 1, false, Title = "ScaleX")]
[ToolkitSampleNumericOption("CustomScaleY", 1, 0.0, 5.0, 1, false, Title = "ScaleY")]
[ToolkitSampleNumericOption("SkewX", 0, -180.0, 180.0, 1, false, Title = "SkewX")]
[ToolkitSampleNumericOption("SkewY", 0, -180.0, 180.0, 1, false, Title = "SkewY")]
[ToolkitSample(id: nameof(LayoutTransformControlSample), "LayoutTransformControl", description: $"A sample for showing how to create and use a {nameof(LayoutTransformControl)}.")]
publicsealedpartialclassLayoutTransformControlSample : Page
{
publicLayoutTransformControlSample()
{
this.InitializeComponent();
}
}
Składnia
XAML
<controls:LayoutTransformControlBackground="Black"HorizontalAlignment="Center"VerticalAlignment="Center"RenderTransformOrigin="0.5,0.5"><controls:LayoutTransformControl.Transform><RotateTransformAngle="90" /></controls:LayoutTransformControl.Transform><BorderHorizontalAlignment="Center"VerticalAlignment="Center"BorderBrush="Red"BorderThickness="5"><Grid><TextBlockPadding="10"Foreground="White"Text="This is a test message." /></Grid></Border></controls:LayoutTransformControl>
Współpracuj z nami w serwisie GitHub
Źródło tej zawartości można znaleźć w witrynie GitHub, gdzie można również tworzyć i przeglądać problemy i żądania ściągnięcia. Więcej informacji znajdziesz w naszym przewodniku dla współtwórców.
Opinia o produkcie Windows Community Toolkit
Windows Community Toolkit to projekt typu open source. Wybierz link, aby przekazać opinię:
Dołącz do serii meetup, aby tworzyć skalowalne rozwiązania sztucznej inteligencji oparte na rzeczywistych przypadkach użycia z innymi deweloperami i ekspertami.