Merge branch 'master' into sampleAppMediaFix

This commit is contained in:
Alexandre Zollinger Chohfi 2021-03-10 20:20:21 -08:00 коммит произвёл GitHub
Родитель 934706adde ad1aaa6c5c
Коммит 0addc9b813
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
123 изменённых файлов: 2626 добавлений и 1660 удалений

Просмотреть файл

@ -0,0 +1,55 @@
// 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.
// This extension is restricted to the .NET 5 because it shares the same BCL
// across all targets, ensuring that the layout of our Nullable<T> mapping type
// will be correct. Exposing this API on older targets (especially .NET Standard)
// is not guaranteed to be correct and could result in invalid memory accesses.
#if NET5_0
using System;
using System.Runtime.CompilerServices;
namespace Microsoft.Toolkit.HighPerformance.Extensions
{
/// <summary>
/// Helpers for working with the <see cref="Nullable{T}"/> type.
/// </summary>
public static class NullableExtensions
{
/// <summary>
/// Returns a reference to the value of the input <see cref="Nullable{T}"/> instance, regardless of whether
/// the <see cref="Nullable{T}.HasValue"/> property is returning <see langword="true"/> or not. If that is not
/// the case, this method will still return a reference to the underlying <see langword="default"/> value.
/// </summary>
/// <typeparam name="T">The type of the underlying value</typeparam>
/// <param name="value">The <see cref="Nullable{T}"/></param>
/// <returns>A reference to the underlying value from the input <see cref="Nullable{T}"/> instance.</returns>
/// <remarks>
/// Note that attempting to mutate the returned reference will not change the value returned by <see cref="Nullable{T}.HasValue"/>.
/// That means that reassigning the value of an empty instance will not make <see cref="Nullable{T}.HasValue"/> return <see langword="true"/>.
/// </remarks>
public static ref T DangerousGetValueOrDefaultReference<T>(this ref T? value)
where T : struct
{
return ref Unsafe.As<T?, RawNullableData<T>>(ref value).Value;
}
/// <summary>
/// Mapping type that reflects the internal layout of the <see cref="Nullable{T}"/> type.
/// See https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Nullable.cs.
/// </summary>
/// <typeparam name="T">The value type wrapped by the current instance.</typeparam>
private struct RawNullableData<T>
where T : struct
{
#pragma warning disable CS0649 // Unassigned fields
public bool HasValue;
public T Value;
#pragma warning restore CS0649
}
}
}
#endif

Просмотреть файл

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Automation;
using Windows.UI.Xaml.Controls;
@ -45,7 +46,7 @@ namespace Microsoft.Toolkit.Uwp.DeveloperTools
}
}
private DispatcherTimer updateTimer;
private DispatcherQueueTimer updateTimer;
private TextBlock controlName;
private TextBlock controlType;
private TextBlock controlAutomationName;
@ -72,7 +73,7 @@ namespace Microsoft.Toolkit.Uwp.DeveloperTools
{
if (updateTimer == null)
{
updateTimer = new DispatcherTimer();
updateTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
updateTimer.Tick += UpdateTimer_Tick;
}

Просмотреть файл

@ -11,6 +11,7 @@ using System.Threading.Tasks;
using Windows.Devices.Input.Preview;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.System;
using Windows.UI;
using Windows.UI.Core;
using Windows.UI.Xaml;
@ -354,7 +355,7 @@ namespace Microsoft.Toolkit.Uwp.Input.GazeInteraction
_gazeCursor = new GazeCursor();
// timer that gets called back if there gaze samples haven't been received in a while
_eyesOffTimer = new DispatcherTimer();
_eyesOffTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
_eyesOffTimer.Tick += OnEyesOff;
// provide a default of GAZE_IDLE_TIME microseconds to fire eyes off
@ -860,7 +861,7 @@ namespace Microsoft.Toolkit.Uwp.Input.GazeInteraction
private readonly List<int> _roots = new List<int>();
private readonly DispatcherTimer _eyesOffTimer;
private readonly DispatcherQueueTimer _eyesOffTimer;
private readonly GazeCursor _gazeCursor;

Просмотреть файл

@ -11,5 +11,10 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.Data
public string Category { get; set; }
public string Thumbnail { get; set; }
public override string ToString()
{
return Title;
}
}
}

Просмотреть файл

@ -272,6 +272,7 @@
<Content Include="Icons\More.png" />
<Content Include="Icons\Notifications.png" />
<Content Include="Icons\Services.png" />
<Content Include="SamplePages\Primitives\SwitchPresenter.png" />
<Content Include="SamplePages\TabbedCommandBar\TabbedCommandBar.png" />
<Content Include="SamplePages\Animations\Effects\FadeBehavior.png" />
<Content Include="SamplePages\ColorPicker\ColorPicker.png" />
@ -495,6 +496,8 @@
<Compile Include="SamplePages\ColorPicker\ColorPickerPage.xaml.cs">
<DependentUpon>ColorPickerPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\EnumValuesExtension\Animal.cs" />
<Compile Include="SamplePages\EnumValuesExtension\AnimalToColorConverter.xaml.cs" />
<Compile Include="SamplePages\EnumValuesExtension\EnumValuesExtensionPage.xaml.cs">
<DependentUpon>EnumValuesExtensionPage.xaml</DependentUpon>
</Compile>
@ -614,6 +617,8 @@
<Content Include="SamplePages\Animations\Behaviors\RotateBehaviorXaml.bind" />
<Content Include="SamplePages\Animations\Effects\EffectAnimations.bind" />
<Content Include="SamplePages\VisualEffectFactory\VisualEffectFactory.bind" />
<Content Include="SamplePages\Animations\Activities\InvokeActionsActivityCode.bind" />
<Content Include="SamplePages\Animations\Activities\StartAnimationActivityCode.bind" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
@ -974,6 +979,9 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Content Include="SamplePages\Primitives\SwitchPresenter.bind">
<SubType>Designer</SubType>
</Content>
<Page Include="SamplePages\TilesBrush\TilesBrushPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>

Просмотреть файл

@ -16,6 +16,7 @@ using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
// TODO Reintroduce graph controls
// using Microsoft.Toolkit.Graph.Converters;
// using Microsoft.Toolkit.Graph.Providers;

Просмотреть файл

@ -158,7 +158,7 @@
Grid.Column="1"
animations:Implicit.Animations="{StaticResource ImplicitOffset}">
<StackPanel>
<TextBlock Style="{StaticResource AboutPageHeader}">Recent Activity</TextBlock>
<TextBlock Style="{StaticResource AboutPageHeader}" Text="Recent Activity"/>
<Grid Margin="0,16,0,0">
<TextBlock FontFamily="Segoe UI"
@ -195,7 +195,7 @@
<StackPanel x:Name="ReleaseNotesPanel"
animations:Implicit.Animations="{StaticResource ImplicitOffset}">
<TextBlock Style="{StaticResource AboutPageHeader}">Release Notes</TextBlock>
<TextBlock Style="{StaticResource AboutPageHeader}" Text="Release Notes"/>
<ItemsControl Margin="0,16,0,0"
ItemTemplate="{StaticResource ReleaseNoteTemplate}"
ItemsSource="{x:Bind GitHubReleases, Mode=OneWay}" />
@ -254,7 +254,7 @@
animations:Implicit.Animations="{StaticResource ImplicitOffset}"
NavigateUri="https://go.microsoft.com/fwlink/?LinkId=521839"
Style="{StaticResource AboutHyperlinkButtonStyle}">
<TextBlock>Privacy statement</TextBlock>
<TextBlock Text="Privacy statement"/>
</HyperlinkButton>
</Grid>
</ScrollViewer>

Просмотреть файл

@ -0,0 +1,15 @@
using Microsoft.Toolkit.Uwp.UI.Animations;
// Fade out the TextBlock
await AnimationBuilder
.Create()
.Opacity(from: 1, to: 0, duration: TimeSpan.FromSeconds(1), easingType: EasingType.Linear)
.StartAsync(MyText);
// Change the text and the sound here...
// Fade the TextBlock back in
await AnimationBuilder
.Create()
.Opacity(to: 1, duration: TimeSpan.FromSeconds(1), easingType: EasingType.Linear)
.StartAsync(MyText);

Просмотреть файл

@ -0,0 +1,40 @@
using Microsoft.Toolkit.Uwp.UI.Animations;
// Move the button down and then back up
AnimationBuilder
.Create()
.Translation(Axis.Y).TimedKeyFrames(b => b
.KeyFrame(TimeSpan.Zero, 0)
.KeyFrame(TimeSpan.FromSeconds(3), 32, EasingType.Linear)
.KeyFrame(TimeSpan.FromSeconds(9), 32, EasingType.Linear)
.KeyFrame(TimeSpan.FromSeconds(12), 0, EasingType.Linear))
.Start(MyButton);
// Fade the image out and then back in
AnimationBuilder
.Create()
.Opacity().TimedKeyFrames(
delay: TimeSpan.FromSeconds(3),
build: b => b
.KeyFrame(TimeSpan.Zero, 1)
.KeyFrame(TimeSpan.FromSeconds(3), 0, EasingType.Linear)
.KeyFrame(TimeSpan.FromSeconds(6), 1, EasingType.Linear))
.Start(MyImage);
// Alternatively, a simpler but less efficient solution involves separate animations
await AnimationBuilder
.Create()
.Translation(Axis.Y, to: 32, duration: TimeSpan.FromSeconds(3), easingType: EasingType.Linear)
.StartAsync(MyButton);
await AnimationBuilder
.Create()
.Opacity(to: 0, duration: TimeSpan.FromSeconds(3), easingType: EasingType.Linear)
.StartAsync(MyImage);
await AnimationBuilder
.Create()
.Opacity(to: 1, duration: TimeSpan.FromSeconds(3), easingType: EasingType.Linear)
.StartAsync(MyImage);
await AnimationBuilder
.Create()
.Translation(Axis.Y, to: 0, duration: TimeSpan.FromSeconds(3), easingType: EasingType.Linear)
.StartAsync(MyButton);

Просмотреть файл

@ -17,11 +17,11 @@
<ComboBox x:Name="FrameSourceGroupCombo" Header="Frame Source Group" HorizontalAlignment="Left" Width="Auto">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding DisplayName}"></TextBlock>
<TextBlock Text="{Binding DisplayName}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock x:Name="CameraErrorTextBlock" Style="{StaticResource ErrorMessageStyle}" Margin="0,0,0,10" Visibility="Collapsed"></TextBlock>
<TextBlock x:Name="CameraErrorTextBlock" Style="{StaticResource ErrorMessageStyle}" Margin="0,0,0,10" Visibility="Collapsed"/>
<Button x:Name="CaptureButton" Content="Capture Video Frame" Margin="0,10" Click="CaptureButton_Click"></Button>
<Image x:Name="CurrentFrameImage" MinWidth="300" Width="400" HorizontalAlignment="Left"></Image>
</StackPanel>

Просмотреть файл

@ -9,7 +9,7 @@
<StackPanel Orientation="Vertical" Margin="20">
<controls:CameraPreview x:Name="CameraPreviewControl">
</controls:CameraPreview>
<TextBlock x:Name="ErrorMessage"></TextBlock>
<TextBlock x:Name="ErrorMessage"/>
<Image x:Name="CurrentFrameImage" MinWidth="300" Width="400" HorizontalAlignment="Left"></Image>
</StackPanel>
</Page>

Просмотреть файл

@ -14,7 +14,7 @@
<StackPanel Orientation="Vertical" Margin="20">
<controls:CameraPreview x:Name="CameraPreviewControl">
</controls:CameraPreview>
<TextBlock x:Name="ErrorMessage" Style="{StaticResource ErrorMessageStyle}"></TextBlock>
<TextBlock x:Name="ErrorMessage" Style="{StaticResource ErrorMessageStyle}"/>
<Image x:Name="CurrentFrameImage" MinWidth="300" Width="400" HorizontalAlignment="Left"></Image>
</StackPanel>
</Page>

Просмотреть файл

@ -95,7 +95,6 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
private Color _strokeColor;
private Color _fillColor;
private bool _selectionChanged = false;
private bool _isParsing = false;
private CanvasGeometry _errorGeometry;
private GeometryStreamReader _reader;
@ -172,9 +171,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
private void ParseData()
{
_data = InputData.Text;
_isParsing = true;
RenderCanvas.Invalidate();
_isParsing = false;
}
private void OnCanvasDraw(CanvasControl sender, CanvasDrawEventArgs args)

Просмотреть файл

@ -36,8 +36,8 @@
MaxWidth="500"
animations:Connected.AnchorElement="{x:Bind HeroElement}">
<TextBlock Text="Header" FontSize="50"></TextBlock>
<TextBlock TextWrapping="WrapWholeWords">Lorem ipsum ...</TextBlock>
<TextBlock Text="Header" FontSize="50"/>
<TextBlock TextWrapping="WrapWholeWords" Text="Lorem ipsum ..."/>
</StackPanel>
</StackPanel>
@ -77,9 +77,9 @@
animations:Connected.AnchorElement="{x:Bind ItemHeroElement}">
<TextBlock Text="{x:Bind item.Title}"
FontSize="50"></TextBlock>
FontSize="50"/>
<TextBlock TextWrapping="WrapWholeWords">Lorem ipsum ...</TextBlock>
<TextBlock TextWrapping="WrapWholeWords" Text="Lorem ipsum ..."/>
</StackPanel>
@ -90,7 +90,7 @@
</StackPanel>
<TextBlock Margin="0,40"
TextWrapping="WrapWholeWords">Lorem Ipsum ...</TextBlock>
TextWrapping="WrapWholeWords" Text="Lorem Ipsum ..."/>
</StackPanel>
<!-- /Page -->

Просмотреть файл

@ -9,7 +9,7 @@
<Grid Padding="20">
<TextBlock VerticalAlignment="Bottom" HorizontalAlignment="Center">This is the first page, Click/Tap the box to navigate to the next page</TextBlock>
<TextBlock VerticalAlignment="Bottom" HorizontalAlignment="Center" Text="This is the first page, Click/Tap the box to navigate to the next page"/>
<Border Height="100"
Width="100"

Просмотреть файл

@ -23,8 +23,8 @@
animations:Connected.Key="item"></Border>
<StackPanel x:Name="HeroDetailsElement" Margin="20,0" VerticalAlignment="Bottom" MaxWidth="500" animations:Connected.AnchorElement="{x:Bind HeroElement}">
<TextBlock Text="Header" FontSize="50"></TextBlock>
<TextBlock TextWrapping="WrapWholeWords">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eleifend ex sit amet blandit lobortis. Curabitur ut diam fringilla, interdum massa sit amet, facilisis erat. Donec vulputate sed ex vel pellentesque. In sodales odio non felis interdum viverra. Morbi in mi mollis, ullamcorper nibh sit amet, sagittis ex. Maecenas dapibus commodo venenatis. Donec at egestas est.</TextBlock>
<TextBlock Text="Header" FontSize="50"/>
<TextBlock TextWrapping="WrapWholeWords" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eleifend ex sit amet blandit lobortis. Curabitur ut diam fringilla, interdum massa sit amet, facilisis erat. Donec vulputate sed ex vel pellentesque. In sodales odio non felis interdum viverra. Morbi in mi mollis, ullamcorper nibh sit amet, sagittis ex. Maecenas dapibus commodo venenatis. Donec at egestas est."/>
</StackPanel>
</StackPanel>

Просмотреть файл

@ -15,8 +15,8 @@
VerticalAlignment="Bottom"
MaxWidth="500"
animations:Connected.AnchorElement="{x:Bind ItemHeroElement}">
<TextBlock Text="{x:Bind item.Title}" FontSize="50"></TextBlock>
<TextBlock TextWrapping="WrapWholeWords">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eleifend ex sit amet blandit lobortis. Curabitur ut diam fringilla, interdum massa sit amet, facilisis erat. Donec vulputate sed ex vel pellentesque. In sodales odio non felis interdum viverra. Morbi in mi mollis, ullamcorper nibh sit amet, sagittis ex. Maecenas dapibus commodo venenatis. Donec at egestas est.</TextBlock>
<TextBlock Text="{x:Bind item.Title}" FontSize="50"/>
<TextBlock TextWrapping="WrapWholeWords" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eleifend ex sit amet blandit lobortis. Curabitur ut diam fringilla, interdum massa sit amet, facilisis erat. Donec vulputate sed ex vel pellentesque. In sodales odio non felis interdum viverra. Morbi in mi mollis, ullamcorper nibh sit amet, sagittis ex. Maecenas dapibus commodo venenatis. Donec at egestas est."/>
</StackPanel>
<Image x:Name="ItemHeroElement"
Height="300" Width="300"
@ -24,7 +24,7 @@
animations:Connected.Key="listItem"/>
</StackPanel>
<TextBlock x:Name="Content" Margin="0,40" TextWrapping="WrapWholeWords" > Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eleifend ex sit amet blandit lobortis. Curabitur ut diam fringilla, interdum massa sit amet, facilisis erat. Donec vulputate sed ex vel pellentesque. In sodales odio non felis interdum viverra. Morbi in mi mollis, ullamcorper nibh sit amet, sagittis ex. Maecenas dapibus commodo venenatis. Donec at egestas est. Donec sit amet ante gravida, feugiat arcu quis, ullamcorper justo. Donec finibus erat lectus, pretium ultrices erat lobortis eu. Nulla sodales libero nisi, a varius urna vehicula et. In rhoncus magna sed felis ultricies aliquet. Sed rhoncus mi id elementum faucibus. Fusce blandit, urna sit amet maximus ultrices, lorem neque fermentum felis, id elementum tellus erat eu eros. Vivamus egestas, est eu sagittis vehicula, lorem nulla hendrerit elit, eu consectetur leo magna eu lorem. Nulla pulvinar augue vitae libero pretium molestie. Nam eget dui velit. Curabitur eu vehicula velit, eu convallis orci. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vestibulum et ipsum turpis. Ut volutpat condimentum elit, sit amet faucibus libero dignissim ac. Aenean vitae euismod lorem. Cras enim neque, hendrerit et dui vitae, viverra porttitor nisi. Aliquam suscipit dictum leo id consequat. Pellentesque condimentum elementum neque. Donec hendrerit nisi quis lorem sagittis, et aliquam dui suscipit. Cras at ligula vitae magna dignissim condimentum nec sagittis mauris. In hac habitasse platea dictumst. Donec tempor, dui et pretium pretium, libero magna iaculis eros, sed consequat nisi orci tempus est. Fusce in rutrum odio. Donec vitae porta metus, et pellentesque turpis. Nullam vestibulum lacus a metus sollicitudin vestibulum. Quisque lacinia quam et urna iaculis mattis. Vestibulum in justo ligula. Donec in dolor lacinia, semper risus eget, bibendum libero. Phasellus elementum odio vel facilisis gravida. Aliquam ac rutrum lacus, et aliquam arcu. Sed tempor rhoncus ipsum, nec viverra diam suscipit non. Nam fermentum commodo auctor. Praesent et nunc id nibh dignissim interdum. Phasellus fermentum mauris tortor, vel laoreet leo maximus sed. Nam sagittis risus lacinia quam dictum rutrum. Pellentesque mollis elit vel mauris eleifend auctor. Donec nec tincidunt odio. Morbi eleifend, turpis ullamcorper convallis vehicula, eros enim lobortis sapien, sit amet consequat risus lorem eu ligula. Quisque hendrerit scelerisque justo vel ultricies. Duis nec erat vulputate, sagittis nisi ut, congue tellus. Integer eget risus nec justo rutrum gravida. Sed eu aliquam nisl, consectetur euismod lacus. Etiam erat ligula, laoreet sed risus non, auctor sollicitudin lacus. Ut tincidunt lectus nec tempor interdum. Proin varius nisi enim, sed finibus urna tincidunt et. Suspendisse venenatis ex ut risus porttitor tempor. Vestibulum mauris ante, blandit in bibendum ac, aliquet quis leo. Aenean at facilisis nunc. Nullam blandit erat at orci tincidunt, in iaculis lorem viverra. Maecenas nec dui porta, tempus nulla nec, rhoncus felis. Ut vitae lectus a metus varius pretium at ut enim. Suspendisse potenti.</TextBlock>
<TextBlock x:Name="Content" Margin="0,40" TextWrapping="WrapWholeWords" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eleifend ex sit amet blandit lobortis. Curabitur ut diam fringilla, interdum massa sit amet, facilisis erat. Donec vulputate sed ex vel pellentesque. In sodales odio non felis interdum viverra. Morbi in mi mollis, ullamcorper nibh sit amet, sagittis ex. Maecenas dapibus commodo venenatis. Donec at egestas est. Donec sit amet ante gravida, feugiat arcu quis, ullamcorper justo. Donec finibus erat lectus, pretium ultrices erat lobortis eu. Nulla sodales libero nisi, a varius urna vehicula et. In rhoncus magna sed felis ultricies aliquet. Sed rhoncus mi id elementum faucibus. Fusce blandit, urna sit amet maximus ultrices, lorem neque fermentum felis, id elementum tellus erat eu eros. Vivamus egestas, est eu sagittis vehicula, lorem nulla hendrerit elit, eu consectetur leo magna eu lorem. Nulla pulvinar augue vitae libero pretium molestie. Nam eget dui velit. Curabitur eu vehicula velit, eu convallis orci. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vestibulum et ipsum turpis. Ut volutpat condimentum elit, sit amet faucibus libero dignissim ac. Aenean vitae euismod lorem. Cras enim neque, hendrerit et dui vitae, viverra porttitor nisi. Aliquam suscipit dictum leo id consequat. Pellentesque condimentum elementum neque. Donec hendrerit nisi quis lorem sagittis, et aliquam dui suscipit. Cras at ligula vitae magna dignissim condimentum nec sagittis mauris. In hac habitasse platea dictumst. Donec tempor, dui et pretium pretium, libero magna iaculis eros, sed consequat nisi orci tempus est. Fusce in rutrum odio. Donec vitae porta metus, et pellentesque turpis. Nullam vestibulum lacus a metus sollicitudin vestibulum. Quisque lacinia quam et urna iaculis mattis. Vestibulum in justo ligula. Donec in dolor lacinia, semper risus eget, bibendum libero. Phasellus elementum odio vel facilisis gravida. Aliquam ac rutrum lacus, et aliquam arcu. Sed tempor rhoncus ipsum, nec viverra diam suscipit non. Nam fermentum commodo auctor. Praesent et nunc id nibh dignissim interdum. Phasellus fermentum mauris tortor, vel laoreet leo maximus sed. Nam sagittis risus lacinia quam dictum rutrum. Pellentesque mollis elit vel mauris eleifend auctor. Donec nec tincidunt odio. Morbi eleifend, turpis ullamcorper convallis vehicula, eros enim lobortis sapien, sit amet consequat risus lorem eu ligula. Quisque hendrerit scelerisque justo vel ultricies. Duis nec erat vulputate, sagittis nisi ut, congue tellus. Integer eget risus nec justo rutrum gravida. Sed eu aliquam nisl, consectetur euismod lacus. Etiam erat ligula, laoreet sed risus non, auctor sollicitudin lacus. Ut tincidunt lectus nec tempor interdum. Proin varius nisi enim, sed finibus urna tincidunt et. Suspendisse venenatis ex ut risus porttitor tempor. Vestibulum mauris ante, blandit in bibendum ac, aliquet quis leo. Aenean at facilisis nunc. Nullam blandit erat at orci tincidunt, in iaculis lorem viverra. Maecenas nec dui porta, tempus nulla nec, rhoncus felis. Ut vitae lectus a metus varius pretium at ut enim. Suspendisse potenti."/>
</StackPanel>
</Grid>
</Page>

Просмотреть файл

@ -38,7 +38,7 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="12">
<TextBlock Text="DataGrid Sample : Mountains" VerticalAlignment="Center" Margin="5,0" Style="{ThemeResource SubtitleTextBlockStyle}"></TextBlock>
<TextBlock Text="DataGrid Sample : Mountains" VerticalAlignment="Center" Margin="5,0" Style="{ThemeResource SubtitleTextBlockStyle}"/>
<AppBarButton Icon="Filter" Label="Filter by">
<AppBarButton.Flyout>
<MenuFlyout>

Просмотреть файл

@ -8,7 +8,7 @@
mc:Ignorable="d" >
<Grid>
<TextBlock Margin="5" Text="In this demo you can't add a child after a Stretch child"></TextBlock>
<TextBlock Margin="5" Text="In this demo you can't add a child after a Stretch child"/>
<Grid Padding="48">
<controls:DockPanel x:Name="SampleDockPanel"
Background="LightGray"

Просмотреть файл

@ -24,7 +24,7 @@
<Grid>
<ScrollViewer Margin="15" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource TitleText}" >TextBlock</TextBlock>
<TextBlock Style="{StaticResource TitleText}" Text="TextBlock"/>
<Border Style="{StaticResource DividingBorder}" />
<controls:DropShadowPanel BlurRadius="@[BlurRadius:DoubleSlider:8.0:0.0-10.0]"
@ -35,17 +35,10 @@
VerticalAlignment="Center"
HorizontalAlignment="Center"
IsMasked="@[Is Masked:Bool:true]">
<TextBlock TextWrapping="Wrap">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In eget sem luctus, gravida diam cursus, rutrum ipsum.
Pellentesque semper magna nec sapien ornare tincidunt. Sed pellentesque, turpis quis laoreet pellentesque, urna sapien efficitur nulla,
at interdum dolor sapien ut odio. Sed ullamcorper sapien velit, id finibus risus gravida vitae. Morbi ac ultrices lectus. Aenean felis
justo, aliquet a risus ut, condimentum malesuada metus. Duis vehicula pharetra dolor vel finibus. Nunc auctor tortor nunc, in varius velit
lobortis vel. Duis viverra, ante id mollis mattis, sem mauris ullamcorper dolor, sed rhoncus est erat eget ligula. Aliquam rutrum velit et
felis sollicitudin, eget dapibus dui accumsan.
</TextBlock>
<TextBlock TextWrapping="Wrap" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. In eget sem luctus, gravida diam cursus, rutrum ipsum. Pellentesque semper magna nec sapien ornare tincidunt. Sed pellentesque, turpis quis laoreet pellentesque, urna sapien efficitur nulla, at interdum dolor sapien ut odio. Sed ullamcorper sapien velit, id finibus risus gravida vitae. Morbi ac ultrices lectus. Aenean felis justo, aliquet a risus ut, condimentum malesuada metus. Duis vehicula pharetra dolor vel finibus. Nunc auctor tortor nunc, in varius velit lobortis vel. Duis viverra, ante id mollis mattis, sem mauris ullamcorper dolor, sed rhoncus est erat eget ligula. Aliquam rutrum velit et felis sollicitudin, eget dapibus dui accumsan."/>
</controls:DropShadowPanel>
<TextBlock Style="{StaticResource TitleText}" >Shapes</TextBlock>
<TextBlock Style="{StaticResource TitleText}" Text="Shapes"/>
<Border Style="{StaticResource DividingBorder}" />
<StackPanel Orientation="Horizontal">
@ -83,7 +76,7 @@
</controls:DropShadowPanel>
</StackPanel>
<TextBlock Style="{StaticResource TitleText}">Images</TextBlock>
<TextBlock Style="{StaticResource TitleText}" Text="Images"/>
<Border Style="{StaticResource DividingBorder}" />
<StackPanel Orientation="Horizontal">

Просмотреть файл

@ -0,0 +1,16 @@
// 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.
namespace Microsoft.Toolkit.Uwp.SampleApp.Enums
{
public enum Animal
{
Cat,
Dog,
Bunny,
Llama,
Parrot,
Squirrel
}
}

Просмотреть файл

@ -0,0 +1,33 @@
// 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 Microsoft.Toolkit.Uwp.SampleApp.Enums;
using Windows.UI;
using Windows.UI.Xaml.Data;
namespace Microsoft.Toolkit.Uwp.SampleApp.Converters
{
public sealed class AnimalToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return (Animal)value switch
{
Animal.Cat => Colors.Coral,
Animal.Dog => Colors.Gray,
Animal.Bunny => Colors.Green,
Animal.Llama => Colors.Beige,
Animal.Parrot => Colors.YellowGreen,
Animal.Squirrel => Colors.SaddleBrown,
_ => throw new ArgumentException("Invalid value", nameof(value))
};
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}

Просмотреть файл

@ -2,11 +2,8 @@
// 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 Microsoft.Toolkit.Uwp.SampleApp.Enums;
using Windows.UI;
using Microsoft.Toolkit.Uwp.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
@ -27,43 +24,4 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
}
}
}
#pragma warning disable SA1403 // File may only contain a single namespace
namespace Microsoft.Toolkit.Uwp.SampleApp.Enums
{
public enum Animal
{
Cat,
Dog,
Bunny,
Parrot,
Squirrel
}
}
namespace Microsoft.Toolkit.Uwp.SampleApp.Converters
{
public sealed class AnimalToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return (Animal)value switch
{
Animal.Cat => Colors.Coral,
Animal.Dog => Colors.Gray,
Animal.Bunny => Colors.Green,
Animal.Parrot => Colors.YellowGreen,
Animal.Squirrel => Colors.SaddleBrown,
_ => throw new ArgumentException("Invalid value", nameof(value))
};
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
#pragma warning restore SA1403
}

Просмотреть файл

@ -52,8 +52,7 @@
VerticalAlignment="Center"
Text="&#xE76F;"
Foreground="{ThemeResource Brush-Alt}"
FontFamily="Segoe MDL2 Assets">
</TextBlock>
FontFamily="Segoe MDL2 Assets"/>
</Grid>
</controls:GridSplitter.Element>
</controls:GridSplitter>

Просмотреть файл

@ -37,40 +37,28 @@
<Border Grid.Column="0"
Grid.Row="0">
<TextBlock>
This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect RowDefinition MinHeight="100"
</TextBlock>
<TextBlock Text="This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect RowDefinition MinHeight='100'"/>
</Border>
<Border Grid.Column="1"
Grid.Row="0">
<TextBlock>
This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect
</TextBlock>
<TextBlock Text="This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect"/>
</Border>
<Border Grid.Column="2"
Grid.Row="0">
<TextBlock>
This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect
</TextBlock>
<TextBlock Text="This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect"/>
</Border>
<Border Grid.Column="0"
Grid.Row="1">
<TextBlock>
This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect
</TextBlock>
<TextBlock Text="This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect"/>
</Border>
<Border Grid.Column="1"
Grid.Row="1">
<TextBlock>
This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect
</TextBlock>
<TextBlock Text="This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect"/>
</Border>
<Border Grid.Column="2"
Grid.Row="1">
<TextBlock>
This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect
</TextBlock>
<TextBlock Text="This text to simulate the resizing feature of the Grid Splitter Control, try to move the splitter to see the effect"/>
</Border>
<!--Column Grid Splitter-->
@ -103,8 +91,7 @@
VerticalAlignment="Center"
Text="&#xE76F;"
Foreground="White"
FontFamily="Segoe MDL2 Assets">
</TextBlock>
FontFamily="Segoe MDL2 Assets"/>
</controls:GridSplitter.Element>
</controls:GridSplitter>

Просмотреть файл

@ -14,8 +14,6 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
public sealed partial class InAppNotificationPage : Page, IXamlRenderListener
{
private ControlTemplate _defaultInAppNotificationControlTemplate;
private ControlTemplate _customInAppNotificationControlTemplate;
private InAppNotification _exampleInAppNotification;
private InAppNotification _exampleCustomInAppNotification;
private InAppNotification _exampleVSCodeInAppNotification;
@ -36,9 +34,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
NotificationDuration = 0;
_exampleInAppNotification = control.FindChild("ExampleInAppNotification") as InAppNotification;
_defaultInAppNotificationControlTemplate = _exampleInAppNotification?.Template;
_exampleCustomInAppNotification = control.FindChild("ExampleCustomInAppNotification") as InAppNotification;
_customInAppNotificationControlTemplate = _exampleCustomInAppNotification?.Template;
_exampleVSCodeInAppNotification = control.FindChild("ExampleVSCodeInAppNotification") as InAppNotification;
_resources = control.Resources;
@ -53,15 +49,15 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
SampleController.Current.RegisterNewCommand("Show notification with random text", (sender, args) =>
{
_exampleVSCodeInAppNotification?.Dismiss();
SetDefaultControlTemplate();
_exampleVSCodeInAppNotification.Dismiss(true);
_exampleCustomInAppNotification.Dismiss(true);
_exampleInAppNotification?.Show(GetRandomText(), NotificationDuration);
});
SampleController.Current.RegisterNewCommand("Show notification with object", (sender, args) =>
{
_exampleVSCodeInAppNotification?.Dismiss();
SetDefaultControlTemplate();
_exampleVSCodeInAppNotification.Dismiss(true);
_exampleCustomInAppNotification.Dismiss(true);
var random = new Random();
_exampleInAppNotification?.Show(new KeyValuePair<int, string>(random.Next(1, 10), GetRandomText()), NotificationDuration);
@ -69,8 +65,8 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
SampleController.Current.RegisterNewCommand("Show notification with buttons (without DataTemplate)", (sender, args) =>
{
_exampleVSCodeInAppNotification?.Dismiss();
SetDefaultControlTemplate();
_exampleVSCodeInAppNotification.Dismiss(true);
_exampleCustomInAppNotification.Dismiss(true);
var grid = new Grid()
{
@ -126,46 +122,30 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
SampleController.Current.RegisterNewCommand("Show notification with buttons (with DataTemplate)", (sender, args) =>
{
_exampleVSCodeInAppNotification?.Dismiss();
SetCustomControlTemplate(); // Use the custom template without the Dismiss button. The DataTemplate will handle re-adding it.
_exampleVSCodeInAppNotification.Dismiss(true);
_exampleInAppNotification.Dismiss(true);
object inAppNotificationWithButtonsTemplate = null;
bool? isTemplatePresent = _resources?.TryGetValue("InAppNotificationWithButtonsTemplate", out inAppNotificationWithButtonsTemplate);
if (isTemplatePresent == true && inAppNotificationWithButtonsTemplate is DataTemplate template)
object inAppNotificationWithButtonsTemplateResource = null;
bool? isTemplatePresent = _resources?.TryGetValue("InAppNotificationWithButtonsTemplate", out inAppNotificationWithButtonsTemplateResource);
if (isTemplatePresent == true && inAppNotificationWithButtonsTemplateResource is DataTemplate inAppNotificationWithButtonsTemplate)
{
_exampleInAppNotification.Show(template, NotificationDuration);
_exampleCustomInAppNotification.Show(inAppNotificationWithButtonsTemplate, NotificationDuration);
}
});
SampleController.Current.RegisterNewCommand("Show notification with Drop Shadow (based on default template)", (sender, args) =>
{
_exampleVSCodeInAppNotification.Dismiss();
SetDefaultControlTemplate();
// Update control template
object inAppNotificationDropShadowControlTemplate = null;
bool? isTemplatePresent = _resources?.TryGetValue("InAppNotificationDropShadowControlTemplate", out inAppNotificationDropShadowControlTemplate);
if (isTemplatePresent == true && inAppNotificationDropShadowControlTemplate is ControlTemplate template)
{
_exampleInAppNotification.Template = template;
}
_exampleInAppNotification.Show(GetRandomText(), NotificationDuration);
});
SampleController.Current.RegisterNewCommand("Show notification with Visual Studio Code template (info notification)", (sender, args) =>
{
_exampleInAppNotification.Dismiss();
_exampleInAppNotification.Dismiss(true);
_exampleCustomInAppNotification.Dismiss(true);
_exampleVSCodeInAppNotification.Show(NotificationDuration);
});
SampleController.Current.RegisterNewCommand("Dismiss", (sender, args) =>
{
// Dismiss all notifications (should not be replicated in production)
_exampleInAppNotification.Dismiss();
_exampleVSCodeInAppNotification.Dismiss();
_exampleInAppNotification.Dismiss(true);
_exampleCustomInAppNotification.Dismiss(true);
_exampleVSCodeInAppNotification.Dismiss(true);
});
}
@ -182,18 +162,6 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
}
}
private void SetDefaultControlTemplate()
{
// Update control template
_exampleInAppNotification.Template = _defaultInAppNotificationControlTemplate;
}
private void SetCustomControlTemplate()
{
// Update control template
_exampleInAppNotification.Template = _customInAppNotificationControlTemplate;
}
private void NotificationDurationTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
int newDuration;

Просмотреть файл

@ -18,6 +18,93 @@
<local:DismissCommand x:Key="DismissCommand" />
<Style TargetType="controls:InAppNotification" x:Key="MSEdgeNotificationTemplate_NoDismissButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="State">
<VisualState x:Name="Collapsed">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)">
<EasingDoubleKeyFrame KeyTime="0" Value="0" />
<EasingDoubleKeyFrame controls:InAppNotification.KeyFrameDuration="{Binding AnimationDuration, RelativeSource={RelativeSource TemplatedParent}}"
Value="{Binding HorizontalOffset, RelativeSource={RelativeSource TemplatedParent}}" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)">
<EasingDoubleKeyFrame KeyTime="0" Value="0" />
<EasingDoubleKeyFrame controls:InAppNotification.KeyFrameDuration="{Binding AnimationDuration, RelativeSource={RelativeSource TemplatedParent}}"
Value="{Binding VerticalOffset, RelativeSource={RelativeSource TemplatedParent}}"/>
</DoubleAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame controls:InAppNotification.KeyFrameDuration="{Binding AnimationDuration, RelativeSource={RelativeSource TemplatedParent}}">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Visible">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)">
<EasingDoubleKeyFrame KeyTime="0" Value="{Binding HorizontalOffset, RelativeSource={RelativeSource TemplatedParent}}" />
<EasingDoubleKeyFrame controls:InAppNotification.KeyFrameDuration="{Binding AnimationDuration, RelativeSource={RelativeSource TemplatedParent}}" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)">
<EasingDoubleKeyFrame KeyTime="0" Value="{Binding VerticalOffset, RelativeSource={RelativeSource TemplatedParent}}" />
<EasingDoubleKeyFrame controls:InAppNotification.KeyFrameDuration="{Binding AnimationDuration, RelativeSource={RelativeSource TemplatedParent}}" Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid x:Name="RootGrid"
RenderTransformOrigin="{TemplateBinding RenderTransformOrigin}"
Margin="{TemplateBinding Margin}"
Padding="{TemplateBinding Padding}"
MaxWidth="{TemplateBinding MaxWidth}"
Visibility="{TemplateBinding Visibility}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid.RenderTransform>
<CompositeTransform />
</Grid.RenderTransform>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter x:Name="PART_Presenter"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
HorizontalContentAlignment="Stretch"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
VerticalContentAlignment="Center"
TextWrapping="WrapWholeWords" />
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DismissTextBlockButtonStyle" TargetType="ButtonBase">
<Setter Property="Background" Value="{ThemeResource HyperlinkButtonBackground}" />
<Setter Property="Foreground" Value="{ThemeResource ApplicationForegroundThemeBrush}" />
@ -72,94 +159,7 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="MSEdgeNotificationTemplate_NoDismissButton" TargetType="controls:InAppNotification">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="State">
<VisualState x:Name="Collapsed">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)">
<EasingDoubleKeyFrame KeyTime="0" Value="0" />
<EasingDoubleKeyFrame controls:InAppNotification.KeyFrameDuration="{Binding AnimationDuration, RelativeSource={RelativeSource TemplatedParent}}"
Value="{Binding HorizontalOffset, RelativeSource={RelativeSource TemplatedParent}}" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)">
<EasingDoubleKeyFrame KeyTime="0" Value="0" />
<EasingDoubleKeyFrame controls:InAppNotification.KeyFrameDuration="{Binding AnimationDuration, RelativeSource={RelativeSource TemplatedParent}}"
Value="{Binding VerticalOffset, RelativeSource={RelativeSource TemplatedParent}}"/>
</DoubleAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame controls:InAppNotification.KeyFrameDuration="{Binding AnimationDuration, RelativeSource={RelativeSource TemplatedParent}}">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Visible">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)">
<EasingDoubleKeyFrame KeyTime="0" Value="{Binding HorizontalOffset, RelativeSource={RelativeSource TemplatedParent}}" />
<EasingDoubleKeyFrame controls:InAppNotification.KeyFrameDuration="{Binding AnimationDuration, RelativeSource={RelativeSource TemplatedParent}}" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)">
<EasingDoubleKeyFrame KeyTime="0" Value="{Binding VerticalOffset, RelativeSource={RelativeSource TemplatedParent}}" />
<EasingDoubleKeyFrame controls:InAppNotification.KeyFrameDuration="{Binding AnimationDuration, RelativeSource={RelativeSource TemplatedParent}}" Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid x:Name="RootGrid"
RenderTransformOrigin="{TemplateBinding RenderTransformOrigin}"
Margin="{TemplateBinding Margin}"
Padding="{TemplateBinding Padding}"
MaxWidth="{TemplateBinding MaxWidth}"
Visibility="{TemplateBinding Visibility}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid.RenderTransform>
<CompositeTransform />
</Grid.RenderTransform>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter x:Name="PART_Presenter"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
HorizontalContentAlignment="Stretch"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
VerticalContentAlignment="Center"
TextWrapping="WrapWholeWords" />
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="InAppNotificationWithButtonsTemplate">
<UserControl>
<Grid DataContext="{Binding ElementName=CurrentPage}">
@ -168,7 +168,7 @@
<VisualState x:Name="NarrowState">
<VisualState.Setters>
<Setter Target="TextBlock.Margin" Value="0" />
<Setter Target="ButtonsStackPanel.(Grid.Row)" Value="1" />
<Setter Target="ButtonsStackPanel.(Grid.Column)" Value="0" />
<Setter Target="ButtonsStackPanel.(Grid.ColumnSpan)" Value="3" />
@ -235,7 +235,7 @@
Height="32"
Width="100"
Command="{StaticResource DismissCommand}"
CommandParameter="{Binding ElementName=ExampleInAppNotification}"
CommandParameter="{Binding ElementName=ExampleCustomInAppNotification}"
AutomationProperties.Name="Ok" />
<Button x:Name="CancelButton"
@ -245,9 +245,8 @@
Height="32"
Width="100"
Command="{StaticResource DismissCommand}"
CommandParameter="{Binding ElementName=ExampleInAppNotification}"
CommandParameter="{Binding ElementName=ExampleCustomInAppNotification}"
AutomationProperties.Name="Cancel"/>
</StackPanel>
<Button x:Name="DismissButton"
@ -261,7 +260,7 @@
FontFamily="Segoe MDL2 Assets"
AutomationProperties.Name="Dismiss"
Command="{StaticResource DismissCommand}"
CommandParameter="{Binding ElementName=ExampleInAppNotification}"
CommandParameter="{Binding ElementName=ExampleCustomInAppNotification}"
VerticalAlignment="Center"
Visibility="{Binding ShowDismissButton, ElementName=ExampleCustomInAppNotification}">
<Button.RenderTransform>
@ -272,97 +271,10 @@
</Grid>
</UserControl>
</DataTemplate>
<ControlTemplate x:Key="InAppNotificationDropShadowControlTemplate">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="State">
<VisualState x:Name="Collapsed">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="RootGrid">
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="RootGrid">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="0:0:0.1">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Visible">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="RootGrid">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid x:Name="RootGrid"
RenderTransformOrigin="{TemplateBinding RenderTransformOrigin}"
Margin="{TemplateBinding Margin}"
MaxWidth="{TemplateBinding MaxWidth}"
Visibility="{TemplateBinding Visibility}">
<Grid.RenderTransform>
<CompositeTransform />
</Grid.RenderTransform>
<controls:DropShadowPanel BlurRadius="8" ShadowOpacity="0.7"
OffsetX="0.2" OffsetY="0.2"
HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<Grid Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter x:Name="PART_Presenter"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
HorizontalContentAlignment="Stretch"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
VerticalContentAlignment="Center"
TextWrapping="WrapWholeWords" />
<Button x:Name="PART_DismissButton"
CornerRadius="20" Height="43" Width="48"
Grid.Column="1"
VerticalAlignment="Top"
Visibility="{Binding ShowDismissButton, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource BoolToVisibilityConverter}}"
FontSize="12"
Style="{StaticResource DismissTextBlockButtonStyle}"
Content="&#xE894;"
FontFamily="Segoe MDL2 Assets"
AutomationProperties.Name="Dismiss">
<Button.RenderTransform>
<TranslateTransform x:Name="DismissButtonTransform" X="25" Y="-7"/>
</Button.RenderTransform>
</Button>
</Grid>
</controls:DropShadowPanel>
</Grid>
</Grid>
</ControlTemplate>
</ResourceDictionary>
</Page.Resources>
<Grid
Background="{ThemeResource Brush-Grey-04}">
<Grid Background="{ThemeResource Brush-Grey-04}">
<StackPanel Padding="20">
<StackPanel Margin="5">
<TextBox x:Name="NotificationDurationTextBox"
@ -391,15 +303,15 @@
</DataTemplate>
</controls:InAppNotification.ContentTemplate>
</controls:InAppNotification>
<controls:InAppNotification x:Name="ExampleCustomInAppNotification"
Style="{StaticResource MSEdgeNotificationTemplate_NoDismissButton}"
Content="This is a test message."
ShowDismissButton="@[ShowDismissButton:Bool:True]"
AnimationDuration="@[AnimationDuration:TimeSpan:100:0-5000]"
VerticalOffset="@[VerticalOffset:DoubleSlider:100.0:-200.0-200.0]"
HorizontalOffset="@[HorizontalOffset:DoubleSlider:0.0:-200.0-200.0]" />
Style="{StaticResource MSEdgeNotificationTemplate_NoDismissButton}"
ShowDismissButton="@[ShowDismissButton]"
AnimationDuration="@[AnimationDuration]"
VerticalOffset="@[VerticalOffset]"
HorizontalOffset="@[HorizontalOffset]"
StackMode="@[StackMode]" />
<controls:InAppNotification x:Name="ExampleVSCodeInAppNotification"
Style="{StaticResource VSCodeNotificationStyle}"

Просмотреть файл

@ -8,11 +8,11 @@
<Page.Resources>
<DataTemplate x:Name="NormalTemplate">
<TextBlock Text="{Binding Title}" Foreground="Green"></TextBlock>
<TextBlock Text="{Binding Title}" Foreground="Green"/>
</DataTemplate>
<DataTemplate x:Name="AlternateTemplate">
<TextBlock Text="{Binding Title}" Foreground="Red"></TextBlock>
<TextBlock Text="{Binding Title}" Foreground="Red"/>
</DataTemplate>
</Page.Resources>

Просмотреть файл

@ -20,7 +20,7 @@
<StackPanel Margin="0,64,0,0">
<wgt:PeoplePicker x:Name="PeopleChooser"
Visibility="{Binding ElementName=LoginButton, Path=UserDetails, Converter={StaticResource NullToVisibilityConverter}}"/>
<TextBlock Margin="0,8,0,0" FontWeight="Bold">Picked People:</TextBlock>
<TextBlock Margin="0,8,0,0" FontWeight="Bold" Text="Picked People:"/>
<ItemsControl ItemsSource="{Binding PickedPeople, ElementName=PeopleChooser}"
Margin="8,0,0,0">
<ItemsControl.ItemTemplate>

Просмотреть файл

@ -0,0 +1,82 @@
<Page
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:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
xmlns:enums="using:Microsoft.Toolkit.Uwp.SampleApp.Enums"
mc:Ignorable="d">
<StackPanel Padding="16">
<!-- Basic Sample -->
<ComboBox x:Name="Lookup" Header="Look up reservation" SelectedIndex="0"
Margin="0,0,0,8">
<x:String>Select an option</x:String>
<x:String>Confirmation Code</x:String>
<x:String>E-ticket number</x:String>
<x:String>Mileage Plan number</x:String>
</ComboBox>
<!-- SwitchPresenter binds to a value -->
<controls:SwitchPresenter Value="{Binding SelectedItem, ElementName=Lookup}">
<!-- And then only dynamically displays the Case with the matching Value -->
<controls:Case Value="Confirmation Code">
<StackPanel>
<TextBox Name="ConfirmationCodeValidator"
ui:TextBoxExtensions.Regex="^[a-zA-Z]{6}$"
Header="Confirmation code"
PlaceholderText="6 letters" />
<TextBlock Visibility="{Binding (ui:TextBoxExtensions.IsValid), ElementName=ConfirmationCodeValidator}" Text="Thanks for entering a valid code!"/>
</StackPanel>
</controls:Case>
<controls:Case Value="E-ticket number">
<StackPanel>
<TextBox Name="TicketValidator"
ui:TextBoxExtensions.Regex="(^\d{10}$)|(^\d{13}$)"
Header="E-ticket number"
PlaceholderText="10 or 13 numbers" />
<TextBlock Visibility="{Binding (ui:TextBoxExtensions.IsValid), ElementName=TicketValidator}" Text="Thanks for entering a valid code!"/>
</StackPanel>
</controls:Case>
<controls:Case Value="Mileage Plan number">
<TextBox Name="PlanValidator"
Header="Mileage Plan #"
PlaceholderText="Mileage Plan #" />
</controls:Case>
<!-- You can also provide a default case if no match is found -->
<controls:Case IsDefault="True">
<TextBlock Text="Please select a way to lookup your reservation above..."/>
</controls:Case>
</controls:SwitchPresenter>
<Border Height="2" Background="Gray" Margin="0,16"/>
<!-- Scenario using an Enum -->
<ComboBox x:Name="AnimalPicker"
Header="Pick an Animal"
ItemsSource="{ui:EnumValues Type=enums:Animal}"
SelectedIndex="0"/>
<controls:SwitchPresenter Value="{Binding SelectedItem, ElementName=AnimalPicker}"
TargetType="enums:Animal"
Padding="16">
<controls:Case Value="Cat">
<TextBlock FontSize="32" Text="🐈"/>
</controls:Case>
<controls:Case Value="Dog">
<TextBlock FontSize="32" Text="🐕"/>
</controls:Case>
<controls:Case Value="Bunny">
<TextBlock FontSize="32" Text="🐇"/>
</controls:Case>
<controls:Case Value="Llama">
<TextBlock FontSize="32" Text="🦙"/>
</controls:Case>
<controls:Case Value="Parrot">
<TextBlock FontSize="32" Text="🦜"/>
</controls:Case>
<controls:Case Value="Squirrel">
<TextBlock FontSize="32" Text="🐿"/>
</controls:Case>
</controls:SwitchPresenter>
</StackPanel>
</Page>

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Просмотреть файл

@ -30,7 +30,7 @@
Margin="20 20 20 5"
HorizontalAlignment="Left"
Orientation="Horizontal">
<TextBlock VerticalAlignment="Center">Orientation field in print dialog</TextBlock>
<TextBlock VerticalAlignment="Center" Text="Orientation field in print dialog"/>
<ToggleSwitch Margin="10,0,0,0"
Name="ShowOrientationSwitch"
OnContent="Show"
@ -40,7 +40,7 @@
Margin="20 5 20 20"
HorizontalAlignment="Left"
Orientation="Horizontal">
<TextBlock VerticalAlignment="Center">Default orientation setting</TextBlock>
<TextBlock VerticalAlignment="Center" Text="Default orientation setting"/>
<ComboBox Margin="10,0,0,0"
Name="DefaultOrientationComboBox">
</ComboBox>

Просмотреть файл

@ -21,7 +21,7 @@
<TextBlock Grid.Column="0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding RangeMin, ElementName=RangeSelectorControl, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:0.##}'}" />
Text="{Binding RangeStart, ElementName=RangeSelectorControl, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:0.##}'}" />
<controls:RangeSelector x:Name="RangeSelectorControl"
Grid.Column="1"
Minimum="@[Minimum:Slider:0:0-100]@"
@ -30,7 +30,7 @@
<TextBlock Grid.Column="2"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Text="{Binding RangeMax, ElementName=RangeSelectorControl, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:0.##}'}" />
Text="{Binding RangeEnd, ElementName=RangeSelectorControl, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:0.##}'}" />
</Grid>
</Grid>
</Page>

Просмотреть файл

@ -23,20 +23,20 @@
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock HorizontalAlignment="Right" Padding="5,0" Grid.Column="0" Grid.Row="0">IsValidEmail</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="0" x:Name="IsValidEmailResult" Foreground="Blue" />
<TextBlock HorizontalAlignment="Right" Padding="5,0" Grid.Column="0" Grid.Row="0" Text="IsValidEmail"/>
<TextBlock Grid.Column="1" Grid.Row="0" x:Name="IsValidEmailResult" FontStyle="Italic"/>
<TextBlock HorizontalAlignment="Right" Padding="5,0" Grid.Column="0" Grid.Row="1">IsValidNumber</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="1" x:Name="IsValidNumberResult" Foreground="Blue" />
<TextBlock HorizontalAlignment="Right" Padding="5,0" Grid.Column="0" Grid.Row="1" Text="IsValidNumber"/>
<TextBlock Grid.Column="1" Grid.Row="1" x:Name="IsValidNumberResult" FontStyle="Italic"/>
<TextBlock HorizontalAlignment="Right" Padding="5,0" Grid.Column="0" Grid.Row="2">IsValidDecimal</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="2" x:Name="IsValidDecimalResult" Foreground="Blue" />
<TextBlock HorizontalAlignment="Right" Padding="5,0" Grid.Column="0" Grid.Row="2" Text="IsValidDecimal"/>
<TextBlock Grid.Column="1" Grid.Row="2" x:Name="IsValidDecimalResult" FontStyle="Italic"/>
<TextBlock HorizontalAlignment="Right" Padding="5,0" Grid.Column="0" Grid.Row="3">IsValidString</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="3" x:Name="IsValidStringResult" Foreground="Blue" />
<TextBlock HorizontalAlignment="Right" Padding="5,0" Grid.Column="0" Grid.Row="3" Text="IsValidString"/>
<TextBlock Grid.Column="1" Grid.Row="3" x:Name="IsValidStringResult" FontStyle="Italic"/>
<TextBlock HorizontalAlignment="Right" Padding="5,0" Grid.Column="0" Grid.Row="4">IsValidPhoneNumber</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="4" x:Name="IsValidPhoneNumberResult" Foreground="Blue" />
<TextBlock HorizontalAlignment="Right" Padding="5,0" Grid.Column="0" Grid.Row="4" Text="IsValidPhoneNumber"/>
<TextBlock Grid.Column="1" Grid.Row="4" x:Name="IsValidPhoneNumberResult" FontStyle="Italic"/>
</Grid>
</StackPanel>
</Grid>

Просмотреть файл

@ -35,10 +35,10 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
IsValidDecimalResult.FontWeight = InputTextBox.Text.IsDecimal() ? FontWeights.Bold : FontWeights.Normal;
IsValidStringResult.Text = InputTextBox.Text.IsCharacterString().ToString();
IsValidPhoneNumberResult.FontWeight = InputTextBox.Text.IsCharacterString() ? FontWeights.Bold : FontWeights.Normal;
IsValidStringResult.FontWeight = InputTextBox.Text.IsCharacterString() ? FontWeights.Bold : FontWeights.Normal;
IsValidPhoneNumberResult.Text = InputTextBox.Text.IsPhoneNumber().ToString();
IsValidPhoneNumberResult.FontWeight = InputTextBox.Text.IsPhoneNumber() ? FontWeights.Bold : FontWeights.Normal;
}
}
}
}

Просмотреть файл

@ -33,34 +33,34 @@
</Grid.RowDefinitions>
<TextBox Name="AlphaTextBox"
ui:TextBoxMask.Mask="9a9a-a9a*"
ui:TextBoxExtensions.Mask="9a9a-a9a*"
Header="Text box with Mask 9a9a-a9a* (9 allows from 0 to 9, a allow from a to Z and * allows both a and 9)"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource MaskedTextBoxStyle}"
Text="TextBoxMask" />
Text="TextBoxMask" />
<TextBox Grid.Row="1"
ui:TextBoxMask.Mask="+1999-9999"
ui:TextBoxMask.PlaceHolder=" "
ui:TextBoxExtensions.Mask="+1999-9999"
ui:TextBoxExtensions.MaskPlaceholder=" "
Header="Text box with Mask +1999-9999 and placeHolder as space (placeholder represents the characters the user can change on runtime)"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource MaskedTextBoxStyle}" />
<TextBox Grid.Row="2"
ui:TextBoxMask.Mask="+\964 799 999 9999"
ui:TextBoxExtensions.Mask="+\964 799 999 9999"
Header="Text box with Mask +964 799 999 9999 (Notice how we escape the first 9 with a backslash)"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource MaskedTextBoxStyle}" />
<TextBox Grid.Row="3"
ui:TextBoxMask.Mask="99\\99\\9999"
ui:TextBoxExtensions.Mask="99\\99\\9999"
Header="Text box with Mask 99\99\9999 (You can escape a backslash with another backslash)"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource MaskedTextBoxStyle}" />
<TextBox Grid.Row="4"
ui:TextBoxMask.CustomMask="5:[1-5],c:[a-c]"
ui:TextBoxMask.Mask="a5c-5c*9"
ui:TextBoxExtensions.CustomMask="5:[1-5],c:[a-c]"
ui:TextBoxExtensions.Mask="a5c-5c*9"
Header="Text box with CustomMask in case you want to define your own variable character like a, 9 and *. Mask: a5c-5c*9, 5: [1-5], c: [a-c]"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource MaskedTextBoxStyle}" />

Просмотреть файл

@ -11,10 +11,10 @@
<TextBox ui:TextBoxExtensions.Mask="9a9a--a9a*"/>
<TextBox ui:TextBoxExtensions.Mask="+1999-9999"
ui:TextBoxExtensions.PlaceHolder=" " />
ui:TextBoxExtensions.MaskPlaceholder=" " />
<TextBox ui:TextBoxExtensions.Mask="+\964 799 999 9999"
ui:TextBoxExtensions.PlaceHolder=" " />
ui:TextBoxExtensions.MaskPlaceholder=" " />
<TextBox ui:TextBoxExtensions.CustomMask="5:[1-5],c:[a-c]"
ui:TextBoxExtensions.Mask="a5c-5c*9" />

Просмотреть файл

@ -34,70 +34,70 @@
<StackPanel Margin="10,10,10,0">
<TextBox Name="PhoneNumberValidator"
ui:TextBoxRegex.Regex="^\s*\+?\s*([0-9][\s-]*){9,}$"
ui:TextBoxExtensions.Regex="^\s*\+?\s*([0-9][\s-]*){9,}$"
Header="Text box with Regex extension for phone number, validation occurs on TextChanged"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource TextBoxRegexStyle}" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="Is Valid: " />
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=PhoneNumberValidator, Converter={StaticResource StringFormatConverter}}" />
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=PhoneNumberValidator, Converter={StaticResource StringFormatConverter}}" />
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="1"
Margin="10,10,10,0">
Margin="10,10,10,0">
<TextBox Name="CharactValidator"
ui:TextBoxRegex.ValidationMode="Dynamic"
ui:TextBoxRegex.ValidationType="Characters"
ui:TextBoxExtensions.ValidationMode="Dynamic"
ui:TextBoxExtensions.ValidationType="Characters"
Header="Text box with ValidationType=Characters, validation occurs at input with ValidationMode=Dynamic and clear only single character when value is invalid"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource TextBoxRegexStyle}"
Text="abcdef" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="Is Valid: " />
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=CharactValidator, Converter={StaticResource StringFormatConverter}}" />
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=CharactValidator, Converter={StaticResource StringFormatConverter}}" />
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="2"
Margin="10,10,10,0">
Margin="10,10,10,0">
<TextBox Name="EmailValidator"
ui:TextBoxRegex.ValidationType="Email"
ui:TextBoxExtensions.ValidationType="Email"
Header="Text box with ValidationType=Email, validation occurs on TextChanged"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource TextBoxRegexStyle}" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="Is Valid: " />
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=EmailValidator, Converter={StaticResource StringFormatConverter}}" />
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=EmailValidator, Converter={StaticResource StringFormatConverter}}" />
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="3"
Margin="10,10,10,0">
<TextBox Name="DecimalValidatorForce"
ui:TextBoxRegex.ValidationMode="Forced"
ui:TextBoxRegex.ValidationType="Decimal"
ui:TextBoxExtensions.ValidationMode="Forced"
ui:TextBoxExtensions.ValidationType="Decimal"
Header="Text box with ValidationType=Decimal, validation occurs on TextChanged and force occurs on lose focus with ValidationMode=Force (333,111 or 333.111)"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource TextBoxRegexStyle}" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="Is Valid: " />
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=DecimalValidatorForce, Converter={StaticResource StringFormatConverter}}" />
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=DecimalValidatorForce, Converter={StaticResource StringFormatConverter}}" />
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="4"
Margin="10,10,10,0">
<TextBox Name="NumberValidatorDynamic"
ui:TextBoxRegex.ValidationMode="Dynamic"
ui:TextBoxRegex.ValidationType="Number"
ui:TextBoxExtensions.ValidationMode="Dynamic"
ui:TextBoxExtensions.ValidationType="Number"
Header="Text box with ValidationType=Number, validation occurs at input with ValidationMode=Dynamic and clear only single character when value is invalid"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource TextBoxRegexStyle}" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="Is Valid: " />
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=NumberValidatorDynamic, Converter={StaticResource StringFormatConverter}}" />
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=NumberValidatorDynamic, Converter={StaticResource StringFormatConverter}}" />
</StackPanel>
</StackPanel>

Просмотреть файл

@ -46,7 +46,7 @@
OffsetY="@[OffsetY:Slider:0:0-150]"
ScrollOrientation="@[Scroll Orientation:Enum:ScrollOrientation.Both]">
<Border Style="{StaticResource BorderStyle}">
<TextBlock Style="{StaticResource TextBlockStyle}" Text="Simple Content"></TextBlock>
<TextBlock Style="{StaticResource TextBlockStyle}" Text="Simple Content"/>
</Border>
</controls:TileControl>
@ -64,11 +64,11 @@
<FlipView x:Name="FlipView">
<Border Style="{StaticResource BorderStyle}">
<TextBlock Style="{StaticResource TextBlockStyle}" Text="Parallax with FlipView &gt;"></TextBlock>
<TextBlock Style="{StaticResource TextBlockStyle}" Text="Parallax with FlipView &gt;"/>
</Border>
<Border Style="{StaticResource BorderStyle}">
<TextBlock Style="{StaticResource TextBlockStyle}" Text="&lt; Parallax with FlipView"></TextBlock>
<TextBlock Style="{StaticResource TextBlockStyle}" Text="&lt; Parallax with FlipView"/>
</Border>
</FlipView>
</controls:TileControl>

Просмотреть файл

@ -13,8 +13,6 @@
mc:Ignorable="d">
<Grid>
<TextBlock Margin="16">
Modify the XAML to change the Title.
</TextBlock>
<TextBlock Margin="16" Text="Modify the XAML to change the Title."/>
</Grid>
</Page>

Просмотреть файл

@ -67,7 +67,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
_logs.Clear();
}
private async void EffectElementHost_EnteredViewport(object sender, EventArgs e)
private void EffectElementHost_EnteredViewport(object sender, EventArgs e)
{
AddLog("Entered viewport");
@ -81,7 +81,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
_effectElement.Source = new BitmapImage(new Uri("ms-appx:///Assets/ToolkitLogo.png"));
}
private async void EffectElementHost_ExitedViewport(object sender, EventArgs e)
private void EffectElementHost_ExitedViewport(object sender, EventArgs e)
{
AddLog("Exited viewport");

Просмотреть файл

@ -32,8 +32,13 @@
</Grid>
</DataTemplate>
<Style TargetType="ListViewItem">
<!-- Change those values to change the WrapPanel's children alignment -->
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="MinHeight" Value="0" />
</Style>
</Page.Resources>
@ -49,16 +54,6 @@
HorizontalSpacing="@[HorizontalSpacing:Slider:5:0-200]@" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<!-- Change those values to change the WrapPanel's children alignment -->
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="0" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="MinHeight" Value="0" />
</Style>
</ListView.ItemContainerStyle>
</ListView>
</Grid>
</Page>

Просмотреть файл

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ani="using:Microsoft.Toolkit.Uwp.UI.Animations"
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
@ -34,6 +35,11 @@
<ui:SurfaceDialOptions />
</ui:TextBoxExtensions.SurfaceDialOptions>
</TextBox>
<controls:SwitchPresenter x:Key="SwitchPresenterControl">
<controls:CaseCollection>
<controls:Case IsDefault="True" />
</controls:CaseCollection>
</controls:SwitchPresenter>
</Page.Resources>
<Grid>

Просмотреть файл

@ -463,6 +463,15 @@
"XamlCodeFile": "/SamplePages/TabbedCommandBar/TabbedCommandBar.bind",
"Icon": "/SamplePages/TabbedCommandBar/TabbedCommandBar.png",
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/TabbedCommandBar.md"
},
{
"Name": "SwitchPresenter",
"Subcategory": "Layout",
"About": "The SwitchPresenter is a ContentPresenter which can allow a developer to mimic a switch statement within XAML.",
"CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/SwitchPresenter",
"XamlCodeFile": "/SamplePages/Primitives/SwitchPresenter.bind",
"Icon": "/SamplePages/Primitives/SwitchPresenter.png",
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/SwitchPresenter.md"
}
]
},
@ -476,6 +485,7 @@
"About": "Activity for Animations to Start another Animation",
"CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Activities",
"XamlCodeFile": "/SamplePages/Animations/Activities/StartAnimationActivity.bind",
"CodeFile": "/SamplePages/Animations/Activities/StartAnimationActivityCode.bind",
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/animations/Fade.md"
},
{
@ -483,6 +493,7 @@
"Subcategory": "Activities",
"About": "Activity chaining Actions from the Behaviors package into an Animation schedule.",
"CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Behaviors/Animations",
"CodeFile": "/SamplePages/Animations/Activities/InvokeActionsActivityCode.bind",
"XamlCodeFile": "/SamplePages/Animations/Activities/InvokeActionsActivity.bind",
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/animations/Fade.md"
},

Просмотреть файл

@ -230,25 +230,29 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
private void ItemContainer_PointerExited(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
var panel = (sender as FrameworkElement).FindDescendant<DropShadowPanel>();
if (panel != null)
if ((sender as FrameworkElement)?.FindDescendant<DropShadowPanel>() is FrameworkElement panel)
{
AnimationBuilder.Create().Opacity(0, duration: TimeSpan.FromMilliseconds(1200)).Start(panel);
AnimationBuilder.Create().Scale(1, duration: TimeSpan.FromMilliseconds(1200)).Start((UIElement)panel.Parent);
if (panel.Parent is UIElement parent)
{
AnimationBuilder.Create().Scale(1, duration: TimeSpan.FromMilliseconds(1200)).Start(parent);
}
}
}
private void ItemContainer_PointerEntered(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse &&
(sender as FrameworkElement)?.FindDescendant<DropShadowPanel>() is FrameworkElement panel)
{
var panel = (sender as FrameworkElement).FindDescendant<DropShadowPanel>();
if (panel != null)
{
panel.Visibility = Visibility.Visible;
panel.Visibility = Visibility.Visible;
AnimationBuilder.Create().Opacity(1, duration: TimeSpan.FromMilliseconds(600)).Start(panel);
AnimationBuilder.Create().Scale(1.1, duration: TimeSpan.FromMilliseconds(600)).Start((UIElement)panel.Parent);
AnimationBuilder.Create().Opacity(1, duration: TimeSpan.FromMilliseconds(600)).Start(panel);
if (panel.Parent is UIElement parent)
{
AnimationBuilder.Create().Scale(1.1, duration: TimeSpan.FromMilliseconds(600)).Start(parent);
}
}
}

Просмотреть файл

@ -25,6 +25,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -35,10 +36,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
AddCompositionAnimationFactory(Properties.Composition.AnchorPoint(axis), (float)to, (float?)from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(Properties.Composition.AnchorPoint(axis), (float)to, (float?)from, delay, duration, repeat, easingType, easingMode);
return this;
}
@ -50,6 +52,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting point for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -59,10 +62,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Vector2? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
AddCompositionAnimationFactory(nameof(Visual.AnchorPoint), to, from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(nameof(Visual.AnchorPoint), to, from, delay, duration, repeat, easingType, easingMode);
return this;
}
@ -74,6 +78,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <param name="layer">The target framework layer to animate.</param>
@ -83,17 +88,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode,
FrameworkLayer layer = FrameworkLayer.Composition)
{
if (layer == FrameworkLayer.Composition)
{
AddCompositionAnimationFactory(nameof(Visual.Opacity), (float)to, (float?)from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(nameof(Visual.Opacity), (float)to, (float?)from, delay, duration, repeat, easingType, easingMode);
}
else
{
AddXamlAnimationFactory(nameof(UIElement.Opacity), to, from, delay, duration, easingType, easingMode);
AddXamlAnimationFactory(nameof(UIElement.Opacity), to, from, delay, duration, repeat, easingType, easingMode);
}
return this;
@ -107,6 +113,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <param name="layer">The target framework layer to animate.</param>
@ -117,17 +124,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode,
FrameworkLayer layer = FrameworkLayer.Composition)
{
if (layer == FrameworkLayer.Composition)
{
AddCompositionAnimationFactory(Properties.Composition.Translation(axis), (float)to, (float?)from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(Properties.Composition.Translation(axis), (float)to, (float?)from, delay, duration, repeat, easingType, easingMode);
}
else
{
AddXamlAnimationFactory(Properties.Xaml.Translation(axis), to, from, delay, duration, easingType, easingMode);
AddXamlAnimationFactory(Properties.Xaml.Translation(axis), to, from, delay, duration, repeat, easingType, easingMode);
}
return this;
@ -140,6 +148,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting point for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <param name="layer">The target framework layer to animate.</param>
@ -149,18 +158,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Vector2? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode,
FrameworkLayer layer = FrameworkLayer.Composition)
{
if (layer == FrameworkLayer.Composition)
{
AddCompositionAnimationFactory(Properties.Composition.TranslationXY(), to, from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(Properties.Composition.TranslationXY(), to, from, delay, duration, repeat, easingType, easingMode);
}
else
{
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.TranslateX), to.X, from?.X, delay, duration, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.TranslateY), to.Y, from?.Y, delay, duration, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.TranslateX), to.X, from?.X, delay, duration, repeat, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.TranslateY), to.Y, from?.Y, delay, duration, repeat, easingType, easingMode);
}
return this;
@ -173,6 +183,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting point for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -182,10 +193,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Vector3? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
return AddCompositionAnimationFactory(Properties.Composition.Translation(), to, from, delay, duration, easingType, easingMode);
return AddCompositionAnimationFactory(Properties.Composition.Translation(), to, from, delay, duration, repeat, easingType, easingMode);
}
/// <summary>
@ -196,6 +208,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -206,10 +219,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
return AddCompositionAnimationFactory(Properties.Composition.Offset(axis), (float)to, (float?)from, delay, duration, easingType, easingMode);
return AddCompositionAnimationFactory(Properties.Composition.Offset(axis), (float)to, (float?)from, delay, duration, repeat, easingType, easingMode);
}
/// <summary>
@ -219,6 +233,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting point for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -228,10 +243,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Vector2? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
AddCompositionAnimationFactory(Properties.Composition.OffsetXY(), to, from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(Properties.Composition.OffsetXY(), to, from, delay, duration, repeat, easingType, easingMode);
return this;
}
@ -243,6 +259,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting point for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -252,10 +269,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Vector3? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
return AddCompositionAnimationFactory(nameof(Visual.Offset), to, from, delay, duration, easingType, easingMode);
return AddCompositionAnimationFactory(nameof(Visual.Offset), to, from, delay, duration, repeat, easingType, easingMode);
}
/// <summary>
@ -265,6 +283,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <param name="layer">The target framework layer to animate.</param>
@ -274,6 +293,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode,
FrameworkLayer layer = FrameworkLayer.Composition)
@ -283,12 +303,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Vector3? from3 = from is null ? null : new((float)(double)from);
Vector3 to3 = new((float)to);
AddCompositionAnimationFactory(nameof(Visual.Scale), to3, from3, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(nameof(Visual.Scale), to3, from3, delay, duration, repeat, easingType, easingMode);
}
else
{
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.ScaleX), to, from, delay, duration, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.ScaleY), to, from, delay, duration, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.ScaleX), to, from, delay, duration, repeat, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.ScaleY), to, from, delay, duration, repeat, easingType, easingMode);
}
return this;
@ -302,6 +322,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <param name="layer">The target framework layer to animate.</param>
@ -312,17 +333,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode,
FrameworkLayer layer = FrameworkLayer.Composition)
{
if (layer == FrameworkLayer.Composition)
{
AddCompositionAnimationFactory(Properties.Composition.Scale(axis), (float)to, (float?)from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(Properties.Composition.Scale(axis), (float)to, (float?)from, delay, duration, repeat, easingType, easingMode);
}
else
{
AddXamlTransformDoubleAnimationFactory(Properties.Xaml.Scale(axis), to, from, delay, duration, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(Properties.Xaml.Scale(axis), to, from, delay, duration, repeat, easingType, easingMode);
}
return this;
@ -335,6 +357,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting point for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <param name="layer">The target framework layer to animate.</param>
@ -344,18 +367,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Vector2? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode,
FrameworkLayer layer = FrameworkLayer.Composition)
{
if (layer == FrameworkLayer.Composition)
{
AddCompositionAnimationFactory(Properties.Composition.ScaleXY(), to, from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(Properties.Composition.ScaleXY(), to, from, delay, duration, repeat, easingType, easingMode);
}
else
{
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.ScaleX), to.X, from?.X, delay, duration, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.ScaleY), to.Y, from?.Y, delay, duration, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.ScaleX), to.X, from?.X, delay, duration, repeat, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.ScaleY), to.Y, from?.Y, delay, duration, repeat, easingType, easingMode);
}
return this;
@ -368,6 +392,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting point for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -377,10 +402,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Vector3? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
return AddCompositionAnimationFactory(nameof(Visual.Scale), to, from, delay, duration, easingType, easingMode);
return AddCompositionAnimationFactory(nameof(Visual.Scale), to, from, delay, duration, repeat, easingType, easingMode);
}
/// <summary>
@ -391,6 +417,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <param name="layer">The target framework layer to animate.</param>
@ -401,17 +428,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode,
FrameworkLayer layer = FrameworkLayer.Composition)
{
if (layer == FrameworkLayer.Composition)
{
AddCompositionAnimationFactory(Properties.Composition.CenterPoint(axis), (float)to, (float?)from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(Properties.Composition.CenterPoint(axis), (float)to, (float?)from, delay, duration, repeat, easingType, easingMode);
}
else
{
AddXamlTransformDoubleAnimationFactory(Properties.Xaml.CenterPoint(axis), to, from, delay, duration, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(Properties.Xaml.CenterPoint(axis), to, from, delay, duration, repeat, easingType, easingMode);
}
return this;
@ -424,6 +452,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting point for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <param name="layer">The target framework layer to animate.</param>
@ -433,18 +462,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Vector2? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode,
FrameworkLayer layer = FrameworkLayer.Composition)
{
if (layer == FrameworkLayer.Composition)
{
AddCompositionAnimationFactory(Properties.Composition.CenterPointXY(), to, from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(Properties.Composition.CenterPointXY(), to, from, delay, duration, repeat, easingType, easingMode);
}
else
{
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.CenterX), to.X, from?.X, delay, duration, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.CenterY), to.Y, from?.Y, delay, duration, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.CenterX), to.X, from?.X, delay, duration, repeat, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.CenterY), to.Y, from?.Y, delay, duration, repeat, easingType, easingMode);
}
return this;
@ -457,6 +487,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting point for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -466,10 +497,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Vector3? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
return AddCompositionAnimationFactory(nameof(Visual.CenterPoint), to, from, delay, duration, easingType, easingMode);
return AddCompositionAnimationFactory(nameof(Visual.CenterPoint), to, from, delay, duration, repeat, easingType, easingMode);
}
/// <summary>
@ -479,6 +511,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <param name="layer">The target framework layer to animate.</param>
@ -488,20 +521,21 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode,
FrameworkLayer layer = FrameworkLayer.Composition)
{
if (layer == FrameworkLayer.Composition)
{
AddCompositionAnimationFactory(nameof(Visual.RotationAngle), (float)to, (float?)from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(nameof(Visual.RotationAngle), (float)to, (float?)from, delay, duration, repeat, easingType, easingMode);
}
else
{
double? fromDegrees = from * Math.PI / 180;
double toDegrees = to * Math.PI / 180;
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.Rotation), toDegrees, fromDegrees, delay, duration, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.Rotation), toDegrees, fromDegrees, delay, duration, repeat, easingType, easingMode);
}
return this;
@ -514,6 +548,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <param name="layer">The target framework layer to animate.</param>
@ -523,17 +558,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode,
FrameworkLayer layer = FrameworkLayer.Composition)
{
if (layer == FrameworkLayer.Composition)
{
AddCompositionAnimationFactory(nameof(Visual.RotationAngleInDegrees), (float)to, (float?)from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(nameof(Visual.RotationAngleInDegrees), (float)to, (float?)from, delay, duration, repeat, easingType, easingMode);
}
else
{
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.Rotation), to, from, delay, duration, easingType, easingMode);
AddXamlTransformDoubleAnimationFactory(nameof(CompositeTransform.Rotation), to, from, delay, duration, repeat, easingType, easingMode);
}
return this;
@ -546,6 +582,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -555,10 +592,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Vector3? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
return AddCompositionAnimationFactory(nameof(Visual.RotationAxis), to, from, delay, duration, easingType, easingMode);
return AddCompositionAnimationFactory(nameof(Visual.RotationAxis), to, from, delay, duration, repeat, easingType, easingMode);
}
/// <summary>
@ -568,6 +606,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -577,10 +616,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Quaternion? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
return AddCompositionAnimationFactory(nameof(Visual.Orientation), to, from, delay, duration, easingType, easingMode);
return AddCompositionAnimationFactory(nameof(Visual.Orientation), to, from, delay, duration, repeat, easingType, easingMode);
}
/// <summary>
@ -590,6 +630,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -599,6 +640,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Matrix4x4? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
@ -623,9 +665,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
fromTranslation = translation3;
}
Scale(toScale, fromScale, delay, duration, easingType, easingMode);
Orientation(toRotation, fromRotation, delay, duration, easingType, easingMode);
Translation(toTranslation, fromTranslation, delay, duration, easingType, easingMode);
Scale(toScale, fromScale, delay, duration, repeat, easingType, easingMode);
Orientation(toRotation, fromRotation, delay, duration, repeat, easingType, easingMode);
Translation(toTranslation, fromTranslation, delay, duration, repeat, easingType, easingMode);
return this;
@ -641,6 +683,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -651,6 +694,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
@ -660,6 +704,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
(float?)from,
delay ?? DefaultDelay,
duration ?? DefaultDuration,
repeat ?? RepeatOption.Once,
easingType,
easingMode);
@ -675,6 +720,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -684,6 +730,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Thickness? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode)
{
@ -693,6 +740,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
(float?)from?.Left,
delay ?? DefaultDelay,
duration ?? DefaultDuration,
repeat ?? RepeatOption.Once,
easingType,
easingMode));
@ -702,6 +750,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
(float?)from?.Top,
delay ?? DefaultDelay,
duration ?? DefaultDuration,
repeat ?? RepeatOption.Once,
easingType,
easingMode));
@ -711,6 +760,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
(float?)from?.Right,
delay ?? DefaultDelay,
duration ?? DefaultDuration,
repeat ?? RepeatOption.Once,
easingType,
easingMode));
@ -720,6 +770,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
(float?)from?.Bottom,
delay ?? DefaultDelay,
duration ?? DefaultDuration,
repeat ?? RepeatOption.Once,
easingType,
easingMode));
@ -734,6 +785,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <param name="layer">The target framework layer to animate.</param>
@ -744,17 +796,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode,
FrameworkLayer layer = FrameworkLayer.Composition)
{
if (layer == FrameworkLayer.Composition)
{
AddCompositionAnimationFactory(Properties.Composition.Size(axis), (float)to, (float?)from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(Properties.Composition.Size(axis), (float)to, (float?)from, delay, duration, repeat, easingType, easingMode);
}
else
{
AddXamlAnimationFactory(Properties.Xaml.Size(axis), to, from, delay, duration, easingType, easingMode);
AddXamlAnimationFactory(Properties.Xaml.Size(axis), to, from, delay, duration, repeat, easingType, easingMode);
}
return this;
@ -767,6 +820,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="from">The optional starting point for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode (defaults to once).</param>
/// <param name="easingType">The optional easing function type for the animation.</param>
/// <param name="easingMode">The optional easing function mode for the animation.</param>
/// <param name="layer">The target framework layer to animate.</param>
@ -776,18 +830,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Vector2? from = null,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null,
EasingType easingType = DefaultEasingType,
EasingMode easingMode = DefaultEasingMode,
FrameworkLayer layer = FrameworkLayer.Composition)
{
if (layer == FrameworkLayer.Composition)
{
AddCompositionAnimationFactory(Properties.Composition.Size(), to, from, delay, duration, easingType, easingMode);
AddCompositionAnimationFactory(Properties.Composition.Size(), to, from, delay, duration, repeat, easingType, easingMode);
}
else
{
AddXamlAnimationFactory(nameof(FrameworkElement.Width), to.X, from?.X, delay, duration, easingType, easingMode);
AddXamlAnimationFactory(nameof(FrameworkElement.Height), to.Y, from?.Y, delay, duration, easingType, easingMode);
AddXamlAnimationFactory(nameof(FrameworkElement.Width), to.X, from?.X, delay, duration, repeat, easingType, easingMode);
AddXamlAnimationFactory(nameof(FrameworkElement.Height), to.Y, from?.Y, delay, duration, repeat, easingType, easingMode);
}
return this;

Просмотреть файл

@ -61,6 +61,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
T? From,
TimeSpan Delay,
TimeSpan Duration,
RepeatOption Repeat,
EasingType EasingType,
EasingMode EasingMode)
: ICompositionAnimationFactory, IXamlAnimationFactory
@ -70,6 +71,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
public CompositionAnimation GetAnimation(CompositionObject targetHint, out CompositionObject? target)
{
CompositionEasingFunction? easingFunction = targetHint.Compositor.TryCreateEasingFunction(EasingType, EasingMode);
(AnimationIterationBehavior iterationBehavior, int iterationCount) = Repeat.ToBehaviorAndCount();
target = null;
@ -80,7 +82,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
GetToAs<bool>(),
GetFromAs<bool>(),
Delay,
Duration);
Duration,
iterationBehavior: iterationBehavior,
iterationCount: iterationCount);
}
if (typeof(T) == typeof(float))
@ -91,7 +95,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
GetFromAs<float>(),
Delay,
Duration,
easingFunction);
easingFunction,
iterationBehavior: iterationBehavior,
iterationCount: iterationCount);
}
if (typeof(T) == typeof(double))
@ -102,7 +108,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
(float?)GetFromAs<double>(),
Delay,
Duration,
easingFunction);
easingFunction,
iterationBehavior: iterationBehavior,
iterationCount: iterationCount);
}
if (typeof(T) == typeof(Vector2))
@ -113,7 +121,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
GetFromAs<Vector2>(),
Delay,
Duration,
easingFunction);
easingFunction,
iterationBehavior: iterationBehavior,
iterationCount: iterationCount);
}
if (typeof(T) == typeof(Vector3))
@ -124,7 +134,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
GetFromAs<Vector3>(),
Delay,
Duration,
easingFunction);
easingFunction,
iterationBehavior: iterationBehavior,
iterationCount: iterationCount);
}
if (typeof(T) == typeof(Vector4))
@ -135,7 +147,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
GetFromAs<Vector4>(),
Delay,
Duration,
easingFunction);
easingFunction,
iterationBehavior: iterationBehavior,
iterationCount: iterationCount);
}
if (typeof(T) == typeof(Color))
@ -146,7 +160,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
GetFromAs<Color>(),
Delay,
Duration,
easingFunction);
easingFunction,
iterationBehavior: iterationBehavior,
iterationCount: iterationCount);
}
if (typeof(T) == typeof(Quaternion))
@ -157,7 +173,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
GetFromAs<Quaternion>(),
Delay,
Duration,
easingFunction);
easingFunction,
iterationBehavior: iterationBehavior,
iterationCount: iterationCount);
}
throw new InvalidOperationException("Invalid animation type");
@ -177,6 +195,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Delay,
Duration,
easingFunction,
Repeat.ToRepeatBehavior(),
enableDependecyAnimations: true);
}
@ -189,6 +208,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Delay,
Duration,
easingFunction,
Repeat.ToRepeatBehavior(),
enableDependecyAnimations: true);
}
@ -201,6 +221,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Delay,
Duration,
easingFunction,
Repeat.ToRepeatBehavior(),
enableDependecyAnimations: true);
}
@ -212,7 +233,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
GetFromAs<Color>(),
Delay,
Duration,
easingFunction);
easingFunction,
Repeat.ToRepeatBehavior());
}
throw new InvalidOperationException("Invalid animation type");
@ -287,6 +309,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
float? From,
TimeSpan Delay,
TimeSpan Duration,
RepeatOption Repeat,
EasingType EasingType,
EasingMode EasingMode)
: ICompositionAnimationFactory
@ -297,7 +320,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Visual visual = (Visual)targetHint;
InsetClip clip = visual.Clip as InsetClip ?? (InsetClip)(visual.Clip = visual.Compositor.CreateInsetClip());
CompositionEasingFunction? easingFunction = clip.Compositor.TryCreateEasingFunction(EasingType, EasingMode);
ScalarKeyFrameAnimation animation = clip.Compositor.CreateScalarKeyFrameAnimation(Property, To, From, Delay, Duration, easingFunction);
(AnimationIterationBehavior iterationBehavior, int iterationCount) = Repeat.ToBehaviorAndCount();
ScalarKeyFrameAnimation animation = clip.Compositor.CreateScalarKeyFrameAnimation(
Property,
To,
From,
Delay,
Duration,
easingFunction,
iterationBehavior: iterationBehavior,
iterationCount: iterationCount);
target = clip;
@ -314,6 +346,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? From,
TimeSpan Delay,
TimeSpan Duration,
RepeatOption Repeat,
EasingType EasingType,
EasingMode EasingMode)
: IXamlAnimationFactory
@ -328,7 +361,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
element.RenderTransform = transform = new CompositeTransform();
}
return transform.CreateDoubleAnimation(Property, To, From, Duration, Delay, EasingType.ToEasingFunction(EasingMode));
return transform.CreateDoubleAnimation(
Property,
To,
From,
Duration,
Delay,
EasingType.ToEasingFunction(EasingMode),
Repeat.ToRepeatBehavior());
}
}

Просмотреть файл

@ -236,6 +236,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The animation duration.</param>
/// <param name="repeatOption">The repeat option for the animation (defaults to one iteration).</param>
/// <param name="delayBehavior">The delay behavior to use (ignored if <paramref name="layer"/> is <see cref="FrameworkLayer.Xaml"/>).</param>
/// <param name="layer">The target framework layer to animate.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
public AnimationBuilder NormalizedKeyFrames<T>(
@ -244,6 +245,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeatOption = null,
AnimationDelayBehavior? delayBehavior = null,
FrameworkLayer layer = FrameworkLayer.Composition)
where T : unmanaged
{
@ -253,7 +255,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
property,
delay,
duration ?? DefaultDuration,
repeatOption ?? RepeatOption.Once);
repeatOption ?? RepeatOption.Once,
delayBehavior ?? DefaultDelayBehavior);
build(builder);
@ -286,6 +289,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The animation duration.</param>
/// <param name="repeatOption">The repeat option for the animation (defaults to one iteration).</param>
/// <param name="delayBehavior">The delay behavior to use (ignored if <paramref name="layer"/> is <see cref="FrameworkLayer.Xaml"/>).</param>
/// <param name="layer">The target framework layer to animate.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
public AnimationBuilder NormalizedKeyFrames<T, TState>(
@ -295,6 +299,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeatOption = null,
AnimationDelayBehavior? delayBehavior = null,
FrameworkLayer layer = FrameworkLayer.Composition)
where T : unmanaged
{
@ -304,7 +309,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
property,
delay,
duration ?? DefaultDuration,
repeatOption ?? RepeatOption.Once);
repeatOption ?? RepeatOption.Once,
delayBehavior ?? DefaultDelayBehavior);
build(builder, state);
@ -334,6 +340,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="build">The callback to use to construct the custom animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="repeat">The repeat option for the animation (defaults to one iteration).</param>
/// <param name="delayBehavior">The delay behavior to use (ignored if <paramref name="layer"/> is <see cref="FrameworkLayer.Xaml"/>).</param>
/// <param name="layer">The target framework layer to animate.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
public AnimationBuilder TimedKeyFrames<T>(
@ -341,12 +348,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Action<ITimedKeyFrameAnimationBuilder<T>> build,
TimeSpan? delay = null,
RepeatOption? repeat = null,
AnimationDelayBehavior? delayBehavior = null,
FrameworkLayer layer = FrameworkLayer.Composition)
where T : unmanaged
{
if (layer == FrameworkLayer.Composition)
{
TimedKeyFrameAnimationBuilder<T>.Composition builder = new(property, delay, repeat ?? RepeatOption.Once);
TimedKeyFrameAnimationBuilder<T>.Composition builder = new(
property,
delay,
repeat ?? RepeatOption.Once,
delayBehavior ?? DefaultDelayBehavior);
build(builder);
@ -374,6 +386,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="build">The callback to use to construct the custom animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="repeatOption">The repeat option for the animation (defaults to one iteration).</param>
/// <param name="delayBehavior">The delay behavior to use (ignored if <paramref name="layer"/> is <see cref="FrameworkLayer.Xaml"/>).</param>
/// <param name="layer">The target framework layer to animate.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
public AnimationBuilder TimedKeyFrames<T, TState>(
@ -382,12 +395,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Action<ITimedKeyFrameAnimationBuilder<T>, TState> build,
TimeSpan? delay = null,
RepeatOption? repeatOption = null,
AnimationDelayBehavior? delayBehavior = null,
FrameworkLayer layer = FrameworkLayer.Composition)
where T : unmanaged
{
if (layer == FrameworkLayer.Composition)
{
TimedKeyFrameAnimationBuilder<T>.Composition builder = new(property, delay, repeatOption ?? RepeatOption.Once);
TimedKeyFrameAnimationBuilder<T>.Composition builder = new(
property,
delay,
repeatOption ?? RepeatOption.Once,
delayBehavior ?? DefaultDelayBehavior);
build(builder, state);

Просмотреть файл

@ -32,9 +32,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Action<INormalizedKeyFrameAnimationBuilder<T>> build,
TimeSpan? delay,
TimeSpan? duration,
RepeatOption? repeatOption)
RepeatOption? repeatOption,
AnimationDelayBehavior? delayBehavior)
{
return Builder.NormalizedKeyFrames(Property, build, delay, duration, repeatOption, Layer);
return Builder.NormalizedKeyFrames(Property, build, delay, duration, repeatOption, delayBehavior, Layer);
}
/// <inheritdoc/>
@ -43,18 +44,20 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Action<INormalizedKeyFrameAnimationBuilder<T>, TState> build,
TimeSpan? delay,
TimeSpan? duration,
RepeatOption? repeatOption)
RepeatOption? repeatOption,
AnimationDelayBehavior? delayBehavior)
{
return Builder.NormalizedKeyFrames(Property, state, build, delay, duration, repeatOption, Layer);
return Builder.NormalizedKeyFrames(Property, state, build, delay, duration, repeatOption, delayBehavior, Layer);
}
/// <inheritdoc/>
public AnimationBuilder TimedKeyFrames(
Action<ITimedKeyFrameAnimationBuilder<T>> build,
TimeSpan? delay,
RepeatOption? repeatOption)
RepeatOption? repeatOption,
AnimationDelayBehavior? delayBehavior)
{
return Builder.TimedKeyFrames(Property, build, delay, repeatOption, Layer);
return Builder.TimedKeyFrames(Property, build, delay, repeatOption, delayBehavior, Layer);
}
/// <inheritdoc/>
@ -62,9 +65,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
TState state,
Action<ITimedKeyFrameAnimationBuilder<T>, TState> build,
TimeSpan? delay,
RepeatOption? repeatOption)
RepeatOption? repeatOption,
AnimationDelayBehavior? delayBehavior)
{
return Builder.TimedKeyFrames(Property, state, build, delay, repeatOption, Layer);
return Builder.TimedKeyFrames(Property, state, build, delay, repeatOption, delayBehavior, Layer);
}
}
@ -81,13 +85,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Action<INormalizedKeyFrameAnimationBuilder<double>> build,
TimeSpan? delay,
TimeSpan? duration,
RepeatOption? repeatOption)
RepeatOption? repeatOption,
AnimationDelayBehavior? delayBehavior)
{
NormalizedKeyFrameAnimationBuilder<double>.Composition builder = new(
Property,
delay,
duration ?? DefaultDuration,
repeatOption ?? RepeatOption.Once);
repeatOption ?? RepeatOption.Once,
delayBehavior ?? DefaultDelayBehavior);
build(builder);
@ -102,13 +108,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Action<INormalizedKeyFrameAnimationBuilder<double>, TState> build,
TimeSpan? delay,
TimeSpan? duration,
RepeatOption? repeatOption)
RepeatOption? repeatOption,
AnimationDelayBehavior? delayBehavior)
{
NormalizedKeyFrameAnimationBuilder<double>.Composition builder = new(
Property,
delay,
duration ?? DefaultDuration,
repeatOption ?? RepeatOption.Once);
repeatOption ?? RepeatOption.Once,
delayBehavior ?? DefaultDelayBehavior);
build(builder, state);
@ -121,9 +129,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
public AnimationBuilder TimedKeyFrames(
Action<ITimedKeyFrameAnimationBuilder<double>> build,
TimeSpan? delay,
RepeatOption? repeatOption)
RepeatOption? repeatOption,
AnimationDelayBehavior? delayBehavior)
{
TimedKeyFrameAnimationBuilder<double>.Composition builder = new(Property, delay, repeatOption ?? RepeatOption.Once);
TimedKeyFrameAnimationBuilder<double>.Composition builder = new(
Property,
delay,
repeatOption ?? RepeatOption.Once,
delayBehavior ?? DefaultDelayBehavior);
build(builder);
@ -137,9 +150,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
TState state,
Action<ITimedKeyFrameAnimationBuilder<double>, TState> build,
TimeSpan? delay,
RepeatOption? repeatOption)
RepeatOption? repeatOption,
AnimationDelayBehavior? delayBehavior)
{
TimedKeyFrameAnimationBuilder<double>.Composition builder = new(Property, delay, repeatOption ?? RepeatOption.Once);
TimedKeyFrameAnimationBuilder<double>.Composition builder = new(
Property,
delay,
repeatOption ?? RepeatOption.Once,
delayBehavior ?? DefaultDelayBehavior);
build(builder, state);
@ -180,7 +198,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Action<INormalizedKeyFrameAnimationBuilder<double>> build,
TimeSpan? delay,
TimeSpan? duration,
RepeatOption? repeatOption)
RepeatOption? repeatOption,
AnimationDelayBehavior? _)
{
NormalizedKeyFrameAnimationBuilder<double>.Xaml builder = new(
Property,
@ -201,7 +220,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
Action<INormalizedKeyFrameAnimationBuilder<double>, TState> build,
TimeSpan? delay,
TimeSpan? duration,
RepeatOption? repeatOption)
RepeatOption? repeatOption,
AnimationDelayBehavior? _)
{
NormalizedKeyFrameAnimationBuilder<double>.Xaml builder = new(
Property,
@ -220,7 +240,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
public AnimationBuilder TimedKeyFrames(
Action<ITimedKeyFrameAnimationBuilder<double>> build,
TimeSpan? delay,
RepeatOption? repeatOption)
RepeatOption? repeatOption,
AnimationDelayBehavior? _)
{
TimedKeyFrameAnimationBuilder<double>.Xaml builder = new(Property, delay, repeatOption ?? RepeatOption.Once);
@ -236,7 +257,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
TState state,
Action<ITimedKeyFrameAnimationBuilder<double>, TState> build,
TimeSpan? delay,
RepeatOption? repeatOption)
RepeatOption? repeatOption,
AnimationDelayBehavior? _)
{
TimedKeyFrameAnimationBuilder<double>.Xaml builder = new(Property, delay, repeatOption ?? RepeatOption.Once);

Просмотреть файл

@ -32,7 +32,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="to">The final value for the animation.</param>
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The animation duration.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat option for the animation.</param>
/// <param name="easingType">The easing function for the animation.</param>
/// <param name="easingMode">The easing mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -42,6 +43,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
T? from,
TimeSpan? delay,
TimeSpan? duration,
RepeatOption? repeat,
EasingType easingType,
EasingMode easingMode)
where T : unmanaged
@ -52,6 +54,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
from,
delay ?? DefaultDelay,
duration ?? DefaultDuration,
repeat ?? RepeatOption.Once,
easingType,
easingMode);
@ -68,7 +71,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="to">The final value for the animation.</param>
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The animation duration.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode for the animation.</param>
/// <param name="easingType">The easing function for the animation.</param>
/// <param name="easingMode">The easing mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -78,6 +82,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
T? from,
TimeSpan? delay,
TimeSpan? duration,
RepeatOption? repeat,
EasingType easingType,
EasingMode easingMode)
where T : unmanaged
@ -88,6 +93,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
from,
delay ?? DefaultDelay,
duration ?? DefaultDuration,
repeat ?? RepeatOption.Once,
easingType,
easingMode);
@ -103,7 +109,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="to">The final value for the animation.</param>
/// <param name="from">The optional starting value for the animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The animation duration.</param>
/// <param name="duration">The optional animation duration.</param>
/// <param name="repeat">The optional repeat mode for the animation.</param>
/// <param name="easingType">The easing function for the animation.</param>
/// <param name="easingMode">The easing mode for the animation.</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
@ -113,6 +120,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
double? from,
TimeSpan? delay,
TimeSpan? duration,
RepeatOption? repeat,
EasingType easingType,
EasingMode easingMode)
{
@ -122,6 +130,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
from,
delay ?? DefaultDelay,
duration ?? DefaultDuration,
repeat ?? RepeatOption.Once,
easingType,
easingMode);

Просмотреть файл

@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using Windows.UI.Composition;
namespace Microsoft.Toolkit.Uwp.UI.Animations
{
@ -19,12 +20,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The animation duration.</param>
/// <param name="repeat">The repeat option for the animation (defaults to one iteration).</param>
/// <param name="delayBehavior">The delay behavior to use (ignored if the animation is not being executed on the composition layer).</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
AnimationBuilder NormalizedKeyFrames(
Action<INormalizedKeyFrameAnimationBuilder<T>> build,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null);
RepeatOption? repeat = null,
AnimationDelayBehavior? delayBehavior = null);
/// <summary>
/// Adds a custom animation based on normalized keyframes ot the current schedule.
@ -35,13 +38,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The animation duration.</param>
/// <param name="repeat">The repeat option for the animation (defaults to one iteration).</param>
/// <param name="delayBehavior">The delay behavior to use (ignored if the animation is not being executed on the composition layer).</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
AnimationBuilder NormalizedKeyFrames<TState>(
TState state,
Action<INormalizedKeyFrameAnimationBuilder<T>, TState> build,
TimeSpan? delay = null,
TimeSpan? duration = null,
RepeatOption? repeat = null);
RepeatOption? repeat = null,
AnimationDelayBehavior? delayBehavior = null);
/// <summary>
/// Adds a custom animation based on timed keyframes to the current schedule.
@ -49,11 +54,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="build">The callback to use to construct the custom animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="repeat">The repeat option for the animation (defaults to one iteration).</param>
/// <param name="delayBehavior">The delay behavior to use (ignored if the animation is not being executed on the composition layer).</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
AnimationBuilder TimedKeyFrames(
Action<ITimedKeyFrameAnimationBuilder<T>> build,
TimeSpan? delay = null,
RepeatOption? repeat = null);
RepeatOption? repeat = null,
AnimationDelayBehavior? delayBehavior = null);
/// <summary>
/// Adds a custom animation based on timed keyframes to the current schedule.
@ -63,11 +70,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="build">The callback to use to construct the custom animation.</param>
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="repeat">The repeat option for the animation (defaults to one iteration).</param>
/// <param name="delayBehavior">The delay behavior to use (ignored if the animation is not being executed on the composition layer).</param>
/// <returns>The current <see cref="AnimationBuilder"/> instance.</returns>
AnimationBuilder TimedKeyFrames<TState>(
TState state,
Action<ITimedKeyFrameAnimationBuilder<T>, TState> build,
TimeSpan? delay = null,
RepeatOption? repeat = null);
RepeatOption? repeat = null,
AnimationDelayBehavior? delayBehavior = null);
}
}

Просмотреть файл

@ -24,6 +24,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <param name="delay">The optional initial delay for the animation.</param>
/// <param name="duration">The animation duration.</param>
/// <param name="repeat">The <see cref="RepeatOption"/> value for the animation</param>
/// <param name="delayBehavior">The delay behavior mode to use.</param>
/// <param name="keyFrames">The list of keyframes to use to build the animation.</param>
/// <returns>A <see cref="CompositionAnimation"/> instance with the specified animation.</returns>
public static CompositionAnimation GetAnimation<TKeyFrame>(
@ -32,6 +33,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
TimeSpan? delay,
TimeSpan duration,
RepeatOption repeat,
AnimationDelayBehavior delayBehavior,
ArraySegment<TKeyFrame> keyFrames)
where TKeyFrame : struct, IKeyFrameInfo
{
@ -237,6 +239,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
if (delay.HasValue)
{
animation.DelayBehavior = delayBehavior;
animation.DelayTime = delay!.Value;
}
@ -251,13 +254,23 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// </summary>
public sealed class Composition : NormalizedKeyFrameAnimationBuilder<T>, AnimationBuilder.ICompositionAnimationFactory
{
/// <summary>
/// The target delay behavior to use.
/// </summary>
private readonly AnimationDelayBehavior delayBehavior;
/// <summary>
/// Initializes a new instance of the <see cref="NormalizedKeyFrameAnimationBuilder{T}.Composition"/> class.
/// </summary>
/// <inheritdoc cref="NormalizedKeyFrameAnimationBuilder{T}"/>
public Composition(string property, TimeSpan? delay, TimeSpan duration, RepeatOption repeat)
/// <param name="property">The target property to animate.</param>
/// <param name="delay">The target delay for the animation.</param>
/// <param name="duration">The target duration for the animation.</param>
/// <param name="repeat">The repeat options for the animation.</param>
/// <param name="delayBehavior">The delay behavior mode to use.</param>
public Composition(string property, TimeSpan? delay, TimeSpan duration, RepeatOption repeat, AnimationDelayBehavior delayBehavior)
: base(property, delay, duration, repeat)
{
this.delayBehavior = delayBehavior;
}
/// <inheritdoc/>
@ -283,6 +296,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
this.delay,
this.duration,
this.repeat,
this.delayBehavior,
this.keyFrames.GetArraySegment());
}
}

Просмотреть файл

@ -20,7 +20,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <summary>
/// Initializes a new instance of the <see cref="NormalizedKeyFrameAnimationBuilder{T}.Xaml"/> class.
/// </summary>
/// <inheritdoc cref="NormalizedKeyFrameAnimationBuilder{T}"/>
/// <param name="property">The target property to animate.</param>
/// <param name="delay">The target delay for the animation.</param>
/// <param name="duration">The target duration for the animation.</param>
/// <param name="repeat">The repeat options for the animation.</param>
public Xaml(string property, TimeSpan? delay, TimeSpan duration, RepeatOption repeat)
: base(property, delay, duration, repeat)
{

Просмотреть файл

@ -19,13 +19,22 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// </summary>
public sealed class Composition : TimedKeyFrameAnimationBuilder<T>, AnimationBuilder.ICompositionAnimationFactory
{
/// <summary>
/// The target delay behavior to use.
/// </summary>
private readonly AnimationDelayBehavior delayBehavior;
/// <summary>
/// Initializes a new instance of the <see cref="TimedKeyFrameAnimationBuilder{T}.Composition"/> class.
/// </summary>
/// <inheritdoc cref="TimedKeyFrameAnimationBuilder{T}"/>
public Composition(string property, TimeSpan? delay, RepeatOption repeat)
/// <param name="property">The target property to animate.</param>
/// <param name="delay">The target delay for the animation.</param>
/// <param name="repeat">The repeat options for the animation.</param>
/// <param name="delayBehavior">The delay behavior mode to use.</param>
public Composition(string property, TimeSpan? delay, RepeatOption repeat, AnimationDelayBehavior delayBehavior)
: base(property, delay, repeat)
{
this.delayBehavior = delayBehavior;
}
/// <inheritdoc/>
@ -56,6 +65,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
this.delay,
duration,
this.repeat,
this.delayBehavior,
keyFrames);
}
}

Просмотреть файл

@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Animation;
@ -149,17 +150,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
listAnimProperty.ListViewBase.ScrollIntoView(parameter);
// give time to the UI thread to scroll the list
var t = listAnimProperty.ListViewBase.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
{
try
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
var t = dispatcherQueue.EnqueueAsync(
async () =>
{
var success = await listAnimProperty.ListViewBase.TryStartConnectedAnimationAsync(connectedAnimation, parameter, listAnimProperty.ElementName);
}
catch (Exception)
{
connectedAnimation.Cancel();
}
});
try
{
var success = await listAnimProperty.ListViewBase.TryStartConnectedAnimationAsync(connectedAnimation, parameter, listAnimProperty.ElementName);
}
catch (Exception)
{
connectedAnimation.Cancel();
}
}, DispatcherQueuePriority.Normal);
animationHandled = true;
}

Просмотреть файл

@ -38,6 +38,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// </summary>
public const EasingMode DefaultEasingMode = EasingMode.EaseInOut;
/// <summary>
/// The default <see cref="AnimationDelayBehavior"/> value used for animations (only applies to composition animations).
/// </summary>
public const AnimationDelayBehavior DefaultDelayBehavior = AnimationDelayBehavior.SetInitialValueBeforeDelay;
/// <summary>
/// The reusable mapping of control points for easing curves for combinations of <see cref="EasingType"/> and <see cref="EasingMode"/> values.
/// </summary>

Просмотреть файл

@ -23,7 +23,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
{
TaskCompletionSource<object?> taskCompletionSource = new TaskCompletionSource<object?>();
storyboard.Completed += (_, _) => taskCompletionSource.SetResult(null);
void OnCompleted(object sender, object e)
{
((Storyboard)sender).Completed -= OnCompleted;
taskCompletionSource.SetResult(null);
}
storyboard.Completed += OnCompleted;
storyboard.Begin();

Просмотреть файл

@ -19,7 +19,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<ProjectReference Include="..\Microsoft.Toolkit.Uwp.UI\Microsoft.Toolkit.Uwp.UI.csproj" />
</ItemGroup>

Просмотреть файл

@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using Windows.UI.Composition;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media.Animation;
@ -103,6 +104,26 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
typeof(Animation),
new PropertyMetadata(RepeatOption.Once));
/// <summary>
/// Gets or sets the delay behavior for the animation. The default value is set to <see cref="AnimationDelayBehavior.SetInitialValueBeforeDelay"/>.
/// This value is applicable when the current animation is used as either an implicit composition animation, or an explicit composition animation.
/// If the current animation is instead running on the XAML layer (if used through <see cref="CustomAnimation{TValue, TKeyFrame}"/>), it will be ignored.
/// </summary>
public AnimationDelayBehavior DelayBehavior
{
get => (AnimationDelayBehavior)GetValue(DelayBehaviorProperty);
set => SetValue(DelayBehaviorProperty, value);
}
/// <summary>
/// Identifies the <seealso cref="DelayBehavior"/> dependency property.
/// </summary>
public static readonly DependencyProperty DelayBehaviorProperty = DependencyProperty.Register(
nameof(DelayBehavior),
typeof(AnimationDelayBehavior),
typeof(Animation),
new PropertyMetadata(AnimationDelayBehavior.SetInitialValueBeforeDelay));
/// <inheritdoc/>
public abstract AnimationBuilder AppendToBuilder(AnimationBuilder builder, TimeSpan? delayHint, TimeSpan? durationHint, EasingType? easingTypeHint, EasingMode? easingModeHint);
}

Просмотреть файл

@ -104,6 +104,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
delay: Delay ?? delayHint ?? DefaultDelay,
duration: Duration ?? durationHint ?? DefaultDuration,
repeatOption: Repeat,
delayBehavior: DelayBehavior,
build: static (b, s) => s.This.AppendToBuilder(b, s.EasingTypeHint, s.EasingModeHint));
}

Просмотреть файл

@ -42,6 +42,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
state: (this, easingTypeHint, easingModeHint),
delay: Delay ?? delayHint ?? DefaultDelay,
duration: Duration ?? durationHint ?? DefaultDuration,
delayBehavior: DelayBehavior,
layer: Layer,
build: static (b, s) => s.This.AppendToBuilder(b, s.EasingTypeHint, s.EasingModeHint));
}

Просмотреть файл

@ -29,7 +29,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
ExplicitTarget,
Delay ?? DefaultDelay,
Duration ?? DefaultDuration,
Repeat);
Repeat,
DelayBehavior);
var (to, from) = GetParsedValues();

Просмотреть файл

@ -25,6 +25,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
From,
Delay ?? delayHint,
Duration ?? durationHint,
Repeat,
EasingType ?? easingTypeHint ?? DefaultEasingType,
EasingMode ?? easingModeHint ?? DefaultEasingMode);
}

Просмотреть файл

@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Markup;
@ -39,7 +40,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Behaviors
typeof(FocusBehavior),
new PropertyMetadata(TimeSpan.FromMilliseconds(100)));
private DispatcherTimer _timer;
private DispatcherQueueTimer _timer;
/// <summary>
/// Initializes a new instance of the <see cref="FocusBehavior"/> class.
@ -120,10 +121,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Behaviors
// This allows us to handle the case where the controls are not loaded in the order we expect.
if (_timer is null)
{
_timer = new DispatcherTimer
{
Interval = FocusEngagementTimeout,
};
_timer = DispatcherQueue.GetForCurrentThread().CreateTimer();
_timer.Interval = FocusEngagementTimeout;
_timer.Tick += OnEngagementTimerTick;
_timer.Start();
}

Просмотреть файл

@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Automation;
using Windows.UI.Xaml.Controls;
@ -20,12 +21,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
[TemplatePart(Name = ContentPresenterPart, Type = typeof(ContentPresenter))]
public partial class InAppNotification : ContentControl
{
private InAppNotificationDismissKind _lastDismissKind;
private DispatcherTimer _dismissTimer = new DispatcherTimer();
private Button _dismissButton;
private VisualStateGroup _visualStateGroup;
private ContentPresenter _contentProvider;
private List<NotificationOptions> _stackedNotificationOptions = new List<NotificationOptions>();
private DispatcherQueueTimer _dismissTimer;
private Button _dismissButton;
private DispatcherQueue _dispatcherQueue;
private InAppNotificationDismissKind _lastDismissKind;
private List<NotificationOptions> _stackedNotificationOptions;
private VisualStateGroup _visualStateGroup;
/// <summary>
/// Initializes a new instance of the <see cref="InAppNotification"/> class.
@ -34,7 +36,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
{
DefaultStyleKey = typeof(InAppNotification);
_dispatcherQueue = DispatcherQueue.GetForCurrentThread();
_dismissTimer = _dispatcherQueue.CreateTimer();
_dismissTimer.Tick += DismissTimer_Tick;
_stackedNotificationOptions = new List<NotificationOptions>();
}
/// <inheritdoc />
@ -160,16 +166,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// <summary>
/// Dismiss the notification
/// </summary>
public void Dismiss()
public void Dismiss(bool dismissAll = false)
{
Dismiss(InAppNotificationDismissKind.Programmatic);
Dismiss(InAppNotificationDismissKind.Programmatic, dismissAll);
}
/// <summary>
/// Dismiss the notification
/// </summary>
/// <param name="dismissKind">Kind of action that triggered dismiss event</param>
private void Dismiss(InAppNotificationDismissKind dismissKind)
/// <param name="dismissAll">Indicates if one or all notifications should be dismissed.</param>
private void Dismiss(InAppNotificationDismissKind dismissKind, bool dismissAll = false)
{
if (_stackedNotificationOptions.Count == 0)
{
@ -179,8 +186,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
_dismissTimer.Stop();
// Dismiss all if requested
if (dismissAll)
{
_stackedNotificationOptions.Clear();
}
else
{
_stackedNotificationOptions.RemoveAt(0);
}
// Continue to display notification if on remaining stacked notification
_stackedNotificationOptions.RemoveAt(0);
if (_stackedNotificationOptions.Any())
{
var notificationOptions = _stackedNotificationOptions[0];
@ -238,8 +254,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
_contentProvider.Content = element;
break;
case DataTemplate dataTemplate:
_contentProvider.ContentTemplate = dataTemplate;
_contentProvider.Content = null;
// Without this check, the dataTemplate will fail to render.
// Why? Setting the ContentTemplate causes the control to re-evaluate it's Content value.
// When we set the ContentTemplate to the same instance of itself, we aren't actually changing the value.
// This means that the Content value won't be re-evaluated and stay null, causing the render to fail.
if (_contentProvider.ContentTemplate != dataTemplate)
{
_contentProvider.ContentTemplate = dataTemplate;
_contentProvider.Content = null;
}
break;
case object content:
_contentProvider.ContentTemplate = ContentTemplate;

Просмотреть файл

@ -33,6 +33,10 @@
<None Include="$(OutDir)\Design\$(MSBuildProjectName).Design*.dll;$(OutDir)\Design\$(MSBuildProjectName).Design*.pdb" Pack="true" PackagePath="lib\$(TargetFramework)\Design" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.UI.Xaml" Version="2.5.0" />
</ItemGroup>
<ItemGroup>
<PRIResource Include="Strings\en-us\Resources.resw" />
</ItemGroup>

Просмотреть файл

@ -6,6 +6,7 @@ using System;
using System.Collections;
using System.Collections.Specialized;
using Microsoft.Toolkit.Uwp.Helpers;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
@ -32,7 +33,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
private static readonly Random Randomizer = new Random();
private int _currentIndex = -1; // current index in the items displayed
private DispatcherTimer _timer; // timer for triggering when to flip the content
private DispatcherQueueTimer _timer; // timer for triggering when to flip the content
private FrameworkElement _currentElement; // FrameworkElement holding a reference to the current element being display
private FrameworkElement _nextElement; // FrameworkElement holding a reference to the next element being display
private FrameworkElement _scroller; // Container Element that's being translated to animate from one item to the next
@ -387,7 +388,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
if (_timer == null)
{
_timer = new DispatcherTimer() { Interval = GetTileDuration() };
_timer = DispatcherQueue.GetForCurrentThread().CreateTimer();
_timer.Interval = GetTileDuration();
_timer.Tick += Timer_Tick;
}

Просмотреть файл

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls">
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:Windows10version1903="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 8)">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls.Core/TabbedCommandBar/TabbedCommandBarItem.xaml" />
@ -88,7 +89,7 @@
Visibility="{Binding TemplateSettings.OverflowButtonVisibility, RelativeSource={RelativeSource Mode=TemplatedParent}}">
<Button.Flyout>
<Flyout Placement="Bottom"
ShouldConstrainToRootBounds="False">
Windows10version1903:ShouldConstrainToRootBounds="False">
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter">
<Setter Property="Padding" Value="0,8" />

Просмотреть файл

@ -9,6 +9,7 @@ using System.Numerics;
using System.Threading;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.System;
using Windows.UI.Composition;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@ -39,7 +40,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
private Size _imageSize = Size.Empty;
private DispatcherTimer _timerAnimation;
private DispatcherQueueTimer _timerAnimation;
/// <summary>
/// A ScrollViewer used for synchronized the move of the <see cref="TileControl"/>
@ -173,9 +174,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
var loadCompletedSource = new TaskCompletionSource<bool>();
_brushVisual = compositor.CreateSurfaceBrush(_imageSurface);
_imageSurface.LoadCompleted += (s, e) =>
void LoadCompleted(LoadedImageSurface sender, LoadedImageSourceLoadCompletedEventArgs args)
{
if (e.Status == LoadedImageSourceLoadStatus.Success)
sender.LoadCompleted -= LoadCompleted;
if (args.Status == LoadedImageSourceLoadStatus.Success)
{
loadCompletedSource.SetResult(true);
}
@ -183,7 +186,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
{
loadCompletedSource.SetException(new ArgumentException("Image loading failed."));
}
};
}
_imageSurface.LoadCompleted += LoadCompleted;
await loadCompletedSource.Task;
_imageSize = _imageSurface.DecodedPhysicalSize;
@ -605,7 +610,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
{
if (_timerAnimation == null)
{
_timerAnimation = new DispatcherTimer();
_timerAnimation = DispatcherQueue.GetForCurrentThread().CreateTimer();
}
else
{

Просмотреть файл

@ -171,7 +171,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
private DataGridRow _focusedRow;
private FrameworkElement _frozenColumnScrollBarSpacer;
private bool _hasNoIndicatorStateStoryboardCompletedHandler;
private DispatcherTimer _hideScrollBarsTimer;
private DispatcherQueueTimer _hideScrollBarsTimer;
// the sum of the widths in pixels of the scrolling columns preceding
// the first displayed scrolling column
@ -6423,19 +6423,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
{
if (!_keepScrollBarsShowing)
{
DispatcherTimer hideScrollBarsTimer = null;
DispatcherQueueTimer hideScrollBarsTimer = null;
if (_hideScrollBarsTimer != null)
{
hideScrollBarsTimer = _hideScrollBarsTimer;
if (hideScrollBarsTimer.IsEnabled)
if (hideScrollBarsTimer.IsRunning)
{
hideScrollBarsTimer.Stop();
}
}
else
{
hideScrollBarsTimer = new DispatcherTimer();
hideScrollBarsTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
hideScrollBarsTimer.Interval = TimeSpan.FromMilliseconds(DATAGRID_noScrollBarCountdownMs);
hideScrollBarsTimer.Tick += HideScrollBarsTimerTick;
_hideScrollBarsTimer = hideScrollBarsTimer;
@ -7958,6 +7958,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
int editingRowSlot = this.EditingRow.Slot;
InvalidateMeasure();
// TODO: Move to DispatcherQueue when FEATURE_VALIDATION_SUMMARY is enabled
this.Dispatcher.BeginInvoke(() =>
{
// It's possible that the DataContext or ItemsSource has changed by the time we reach this code,
@ -8207,7 +8208,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
}
else
{
if (_hideScrollBarsTimer != null && _hideScrollBarsTimer.IsEnabled)
if (_hideScrollBarsTimer != null && _hideScrollBarsTimer.IsRunning)
{
_hideScrollBarsTimer.Stop();
_hideScrollBarsTimer.Start();
@ -8289,7 +8290,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
private void StopHideScrollBarsTimer()
{
if (_hideScrollBarsTimer != null && _hideScrollBarsTimer.IsEnabled)
if (_hideScrollBarsTimer != null && _hideScrollBarsTimer.IsRunning)
{
_hideScrollBarsTimer.Stop();
}
@ -8762,6 +8763,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
// If the number of errors has changed, then the ValidationSummary will be a different size,
// and we need to delay our call to ScrollSlotIntoView
this.InvalidateMeasure();
// TODO: Move to DispatcherQueue when FEATURE_VALIDATION_SUMMARY is enabled
this.Dispatcher.BeginInvoke(() =>
{
// It's possible that the DataContext or ItemsSource has changed by the time we reach this code,

Просмотреть файл

@ -17,6 +17,10 @@
<None Include="$(OutDir)\Design\$(MSBuildProjectName).Design*.dll;$(OutDir)\Design\$(MSBuildProjectName).Design*.pdb" Pack="true" PackagePath="lib\$(TargetFramework)\Design" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.UI.Xaml" Version="2.5.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>

Просмотреть файл

@ -8,6 +8,7 @@ using System.Collections.Specialized;
using System.Globalization;
using Microsoft.Toolkit.Uwp.Helpers;
using Microsoft.Toolkit.Uwp.UI.Controls.ColorPickerConverters;
using Windows.System;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@ -74,7 +75,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
private HsvColor? savedHsvColor = null;
private Color? savedHsvColorRgbEquivalent = null;
private Color? updatedRgbColor = null;
private DispatcherTimer dispatcherTimer = null;
private DispatcherQueueTimer dispatcherQueueTimer = null;
private ColorSpectrum ColorSpectrumControl;
private ColorPickerSlider ColorSpectrumAlphaSlider;
@ -134,7 +135,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
this.ConnectCallbacks(true);
this.SetDefaultPalette();
this.StartDispatcherTimer();
this.StartDispatcherQueueTimer();
}
/// <summary>
@ -142,7 +143,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// </summary>
~ColorPicker()
{
this.StopDispatcherTimer();
this.StopDispatcherQueueTimer();
this.CustomPaletteColors.CollectionChanged -= CustomPaletteColors_CollectionChanged;
}
@ -1068,29 +1069,27 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
*
***************************************************************************************/
private void StartDispatcherTimer()
private void StartDispatcherQueueTimer()
{
this.dispatcherTimer = new DispatcherTimer()
{
Interval = new TimeSpan(0, 0, 0, 0, ColorUpdateInterval)
};
this.dispatcherTimer.Tick += DispatcherTimer_Tick;
this.dispatcherTimer.Start();
this.dispatcherQueueTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
this.dispatcherQueueTimer.Interval = new TimeSpan(0, 0, 0, 0, ColorUpdateInterval);
this.dispatcherQueueTimer.Tick += DispatcherQueueTimer_Tick;
this.dispatcherQueueTimer.Start();
return;
}
private void StopDispatcherTimer()
private void StopDispatcherQueueTimer()
{
if (this.dispatcherTimer != null)
if (this.dispatcherQueueTimer != null)
{
this.dispatcherTimer.Stop();
this.dispatcherQueueTimer.Stop();
}
return;
}
private void DispatcherTimer_Tick(object sender, object e)
private void DispatcherQueueTimer_Tick(object sender, object e)
{
if (this.updatedRgbColor != null)
{

Просмотреть файл

@ -30,6 +30,10 @@
<None Include="$(OutDir)\Design\$(MSBuildProjectName).Design*.dll;$(OutDir)\Design\$(MSBuildProjectName).Design*.pdb" Pack="true" PackagePath="lib\$(TargetFramework)\Design" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.UI.Xaml" Version="2.5.0" />
</ItemGroup>
<ItemGroup>
<PRIResource Include="Strings\en-us\Resources.resw" />
</ItemGroup>

Просмотреть файл

@ -0,0 +1,58 @@
// 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 Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// RangeSelector is a "double slider" control for range values.
/// </summary>
public partial class RangeSelector : Control
{
/// <summary>
/// Event raised when lower or upper range thumbs start being dragged.
/// </summary>
public event DragStartedEventHandler ThumbDragStarted;
/// <summary>
/// Event raised when lower or upper range thumbs end being dragged.
/// </summary>
public event DragCompletedEventHandler ThumbDragCompleted;
/// <summary>
/// Event raised when lower or upper range values are changed.
/// </summary>
public event EventHandler<RangeChangedEventArgs> ValueChanged;
/// <summary>
/// Called before the <see cref="ThumbDragStarted"/> event occurs.
/// </summary>
/// <param name="e">Event data for the event.</param>
protected virtual void OnThumbDragStarted(DragStartedEventArgs e)
{
ThumbDragStarted?.Invoke(this, e);
}
/// <summary>
/// Called before the <see cref="ThumbDragCompleted"/> event occurs.
/// </summary>
/// <param name="e">Event data for the event.</param>
protected virtual void OnThumbDragCompleted(DragCompletedEventArgs e)
{
ThumbDragCompleted?.Invoke(this, e);
}
/// <summary>
/// Called before the <see cref="ValueChanged"/> event occurs.
/// </summary>
/// <param name="e"><see cref="RangeChangedEventArgs"/> event data for the event.</param>
protected virtual void OnValueChanged(RangeChangedEventArgs e)
{
ValueChanged?.Invoke(this, e);
}
}
}

Просмотреть файл

@ -0,0 +1,116 @@
// 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 Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// RangeSelector is a "double slider" control for range values.
/// </summary>
public partial class RangeSelector : Control
{
private void MinThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
_absolutePosition += e.HorizontalChange;
RangeStart = DragThumb(_minThumb, 0, Canvas.GetLeft(_maxThumb), _absolutePosition);
if (_toolTipText != null)
{
UpdateToolTipText(this, _toolTipText, RangeStart);
}
}
private void MaxThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
_absolutePosition += e.HorizontalChange;
RangeEnd = DragThumb(_maxThumb, Canvas.GetLeft(_minThumb), DragWidth(), _absolutePosition);
if (_toolTipText != null)
{
UpdateToolTipText(this, _toolTipText, RangeEnd);
}
}
private void MinThumb_DragStarted(object sender, DragStartedEventArgs e)
{
OnThumbDragStarted(e);
Thumb_DragStarted(_minThumb);
}
private void MaxThumb_DragStarted(object sender, DragStartedEventArgs e)
{
OnThumbDragStarted(e);
Thumb_DragStarted(_maxThumb);
}
private void Thumb_DragCompleted(object sender, DragCompletedEventArgs e)
{
OnThumbDragCompleted(e);
OnValueChanged(sender.Equals(_minThumb) ? new RangeChangedEventArgs(_oldValue, RangeStart, RangeSelectorProperty.MinimumValue) : new RangeChangedEventArgs(_oldValue, RangeEnd, RangeSelectorProperty.MaximumValue));
SyncThumbs();
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Collapsed;
}
VisualStateManager.GoToState(this, "Normal", true);
}
private double DragWidth()
{
return _containerCanvas.ActualWidth - _maxThumb.Width;
}
private double DragThumb(Thumb thumb, double min, double max, double nextPos)
{
nextPos = Math.Max(min, nextPos);
nextPos = Math.Min(max, nextPos);
Canvas.SetLeft(thumb, nextPos);
if (_toolTipText != null && _toolTip != null)
{
var thumbCenter = nextPos + (thumb.Width / 2);
_toolTip.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
var ttWidth = _toolTip.ActualWidth / 2;
Canvas.SetLeft(_toolTip, thumbCenter - ttWidth);
}
return Minimum + ((nextPos / DragWidth()) * (Maximum - Minimum));
}
private void Thumb_DragStarted(Thumb thumb)
{
var useMin = thumb == _minThumb;
var otherThumb = useMin ? _maxThumb : _minThumb;
_absolutePosition = Canvas.GetLeft(thumb);
Canvas.SetZIndex(thumb, 10);
Canvas.SetZIndex(otherThumb, 0);
_oldValue = RangeStart;
if (_toolTipText != null && _toolTip != null)
{
_toolTip.Visibility = Visibility.Visible;
var thumbCenter = _absolutePosition + (thumb.Width / 2);
_toolTip.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
var ttWidth = _toolTip.ActualWidth / 2;
Canvas.SetLeft(_toolTip, thumbCenter - ttWidth);
UpdateToolTipText(this, _toolTipText, useMin ? RangeStart : RangeEnd);
}
VisualStateManager.GoToState(this, useMin ? "MinPressed" : "MaxPressed", true);
}
}
}

Просмотреть файл

@ -0,0 +1,91 @@
// 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 Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// RangeSelector is a "double slider" control for range values.
/// </summary>
public partial class RangeSelector : Control
{
private readonly DispatcherQueueTimer keyDebounceTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
private void MinThumb_KeyDown(object sender, KeyRoutedEventArgs e)
{
switch (e.Key)
{
case VirtualKey.Left:
RangeStart -= StepFrequency;
SyncThumbs(fromMinKeyDown: true);
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Visible;
}
e.Handled = true;
break;
case VirtualKey.Right:
RangeStart += StepFrequency;
SyncThumbs(fromMinKeyDown: true);
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Visible;
}
e.Handled = true;
break;
}
}
private void MaxThumb_KeyDown(object sender, KeyRoutedEventArgs e)
{
switch (e.Key)
{
case VirtualKey.Left:
RangeEnd -= StepFrequency;
SyncThumbs(fromMaxKeyDown: true);
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Visible;
}
e.Handled = true;
break;
case VirtualKey.Right:
RangeEnd += StepFrequency;
SyncThumbs(fromMaxKeyDown: true);
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Visible;
}
e.Handled = true;
break;
}
}
private void Thumb_KeyUp(object sender, KeyRoutedEventArgs e)
{
switch (e.Key)
{
case VirtualKey.Left:
case VirtualKey.Right:
if (_toolTip != null)
{
keyDebounceTimer.Debounce(
() => _toolTip.Visibility = Visibility.Collapsed,
TimeToHideToolTipOnKeyUp);
}
e.Handled = true;
break;
}
}
}
}

Просмотреть файл

@ -0,0 +1,114 @@
// 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 Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// RangeSelector is a "double slider" control for range values.
/// </summary>
public partial class RangeSelector : Control
{
private void ContainerCanvas_PointerEntered(object sender, PointerRoutedEventArgs e)
{
VisualStateManager.GoToState(this, "PointerOver", false);
}
private void ContainerCanvas_PointerExited(object sender, PointerRoutedEventArgs e)
{
var position = e.GetCurrentPoint(_containerCanvas).Position.X;
var normalizedPosition = ((position / DragWidth()) * (Maximum - Minimum)) + Minimum;
if (_pointerManipulatingMin)
{
_pointerManipulatingMin = false;
_containerCanvas.IsHitTestVisible = true;
OnValueChanged(new RangeChangedEventArgs(RangeStart, normalizedPosition, RangeSelectorProperty.MinimumValue));
}
else if (_pointerManipulatingMax)
{
_pointerManipulatingMax = false;
_containerCanvas.IsHitTestVisible = true;
OnValueChanged(new RangeChangedEventArgs(RangeEnd, normalizedPosition, RangeSelectorProperty.MaximumValue));
}
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Collapsed;
}
VisualStateManager.GoToState(this, "Normal", false);
}
private void ContainerCanvas_PointerReleased(object sender, PointerRoutedEventArgs e)
{
var position = e.GetCurrentPoint(_containerCanvas).Position.X;
var normalizedPosition = ((position / DragWidth()) * (Maximum - Minimum)) + Minimum;
if (_pointerManipulatingMin)
{
_pointerManipulatingMin = false;
_containerCanvas.IsHitTestVisible = true;
OnValueChanged(new RangeChangedEventArgs(RangeStart, normalizedPosition, RangeSelectorProperty.MinimumValue));
}
else if (_pointerManipulatingMax)
{
_pointerManipulatingMax = false;
_containerCanvas.IsHitTestVisible = true;
OnValueChanged(new RangeChangedEventArgs(RangeEnd, normalizedPosition, RangeSelectorProperty.MaximumValue));
}
SyncThumbs();
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Collapsed;
}
}
private void ContainerCanvas_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var position = e.GetCurrentPoint(_containerCanvas).Position.X;
var normalizedPosition = ((position / DragWidth()) * (Maximum - Minimum)) + Minimum;
if (_pointerManipulatingMin && normalizedPosition < RangeEnd)
{
RangeStart = DragThumb(_minThumb, 0, Canvas.GetLeft(_maxThumb), position);
UpdateToolTipText(this, _toolTipText, RangeStart);
}
else if (_pointerManipulatingMax && normalizedPosition > RangeStart)
{
RangeEnd = DragThumb(_maxThumb, Canvas.GetLeft(_minThumb), DragWidth(), position);
UpdateToolTipText(this, _toolTipText, RangeEnd);
}
}
private void ContainerCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
{
var position = e.GetCurrentPoint(_containerCanvas).Position.X;
var normalizedPosition = position * Math.Abs(Maximum - Minimum) / DragWidth();
double upperValueDiff = Math.Abs(RangeEnd - normalizedPosition);
double lowerValueDiff = Math.Abs(RangeStart - normalizedPosition);
if (upperValueDiff < lowerValueDiff)
{
RangeEnd = normalizedPosition;
_pointerManipulatingMax = true;
Thumb_DragStarted(_maxThumb);
}
else
{
RangeStart = normalizedPosition;
_pointerManipulatingMin = true;
Thumb_DragStarted(_minThumb);
}
SyncThumbs();
}
}
}

Просмотреть файл

@ -0,0 +1,275 @@
// 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 Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// RangeSelector is a "double slider" control for range values.
/// </summary>
public partial class RangeSelector : Control
{
/// <summary>
/// Identifies the <see cref="Minimum"/> property.
/// </summary>
public static readonly DependencyProperty MinimumProperty =
DependencyProperty.Register(
nameof(Minimum),
typeof(double),
typeof(RangeSelector),
new PropertyMetadata(DefaultMinimum, MinimumChangedCallback));
/// <summary>
/// Identifies the <see cref="Maximum"/> property.
/// </summary>
public static readonly DependencyProperty MaximumProperty =
DependencyProperty.Register(
nameof(Maximum),
typeof(double),
typeof(RangeSelector),
new PropertyMetadata(DefaultMaximum, MaximumChangedCallback));
/// <summary>
/// Identifies the <see cref="RangeStart"/> property.
/// </summary>
public static readonly DependencyProperty RangeStartProperty =
DependencyProperty.Register(
nameof(RangeStart),
typeof(double),
typeof(RangeSelector),
new PropertyMetadata(DefaultMinimum, RangeMinChangedCallback));
/// <summary>
/// Identifies the <see cref="RangeEnd"/> property.
/// </summary>
public static readonly DependencyProperty RangeEndProperty =
DependencyProperty.Register(
nameof(RangeEnd),
typeof(double),
typeof(RangeSelector),
new PropertyMetadata(DefaultMaximum, RangeMaxChangedCallback));
/// <summary>
/// Identifies the <see cref="StepFrequency"/> property.
/// </summary>
public static readonly DependencyProperty StepFrequencyProperty =
DependencyProperty.Register(
nameof(StepFrequency),
typeof(double),
typeof(RangeSelector),
new PropertyMetadata(DefaultStepFrequency));
/// <summary>
/// Gets or sets the absolute minimum value of the range.
/// </summary>
/// <value>
/// The minimum.
/// </value>
public double Minimum
{
get => (double)GetValue(MinimumProperty);
set => SetValue(MinimumProperty, value);
}
/// <summary>
/// Gets or sets the absolute maximum value of the range.
/// </summary>
/// <value>
/// The maximum.
/// </value>
public double Maximum
{
get => (double)GetValue(MaximumProperty);
set => SetValue(MaximumProperty, value);
}
/// <summary>
/// Gets or sets the current selected lower limit value of the range, modifiable by the user.
/// </summary>
/// <value>
/// The current lower limit.
/// </value>
public double RangeStart
{
get => (double)GetValue(RangeStartProperty);
set => SetValue(RangeStartProperty, value);
}
/// <summary>
/// Gets or sets the current selected upper limit value of the range, modifiable by the user.
/// </summary>
/// <value>
/// The current upper limit.
/// </value>
public double RangeEnd
{
get => (double)GetValue(RangeEndProperty);
set => SetValue(RangeEndProperty, value);
}
/// <summary>
/// Gets or sets the value part of a value range that steps should be created for.
/// </summary>
/// <value>
/// The value part of a value range that steps should be created for.
/// </value>
public double StepFrequency
{
get => (double)GetValue(StepFrequencyProperty);
set => SetValue(StepFrequencyProperty, value);
}
private static void MinimumChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var rangeSelector = d as RangeSelector;
if (rangeSelector == null || !rangeSelector._valuesAssigned)
{
return;
}
var newValue = (double)e.NewValue;
var oldValue = (double)e.OldValue;
if (rangeSelector.Maximum < newValue)
{
rangeSelector.Maximum = newValue + Epsilon;
}
if (rangeSelector.RangeStart < newValue)
{
rangeSelector.RangeStart = newValue;
}
if (rangeSelector.RangeEnd < newValue)
{
rangeSelector.RangeEnd = newValue;
}
if (newValue != oldValue)
{
rangeSelector.SyncThumbs();
}
}
private static void MaximumChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var rangeSelector = d as RangeSelector;
if (rangeSelector == null || !rangeSelector._valuesAssigned)
{
return;
}
var newValue = (double)e.NewValue;
var oldValue = (double)e.OldValue;
if (rangeSelector.Minimum > newValue)
{
rangeSelector.Minimum = newValue - Epsilon;
}
if (rangeSelector.RangeEnd > newValue)
{
rangeSelector.RangeEnd = newValue;
}
if (rangeSelector.RangeStart > newValue)
{
rangeSelector.RangeStart = newValue;
}
if (newValue != oldValue)
{
rangeSelector.SyncThumbs();
}
}
private static void RangeMinChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var rangeSelector = d as RangeSelector;
if (rangeSelector == null)
{
return;
}
rangeSelector._minSet = true;
if (!rangeSelector._valuesAssigned)
{
return;
}
var newValue = (double)e.NewValue;
rangeSelector.RangeMinToStepFrequency();
if (rangeSelector._valuesAssigned)
{
if (newValue < rangeSelector.Minimum)
{
rangeSelector.RangeStart = rangeSelector.Minimum;
}
else if (newValue > rangeSelector.Maximum)
{
rangeSelector.RangeStart = rangeSelector.Maximum;
}
rangeSelector.SyncActiveRectangle();
// If the new value is greater than the old max, move the max also
if (newValue > rangeSelector.RangeEnd)
{
rangeSelector.RangeEnd = newValue;
}
}
rangeSelector.SyncThumbs();
}
private static void RangeMaxChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var rangeSelector = d as RangeSelector;
if (rangeSelector == null)
{
return;
}
rangeSelector._maxSet = true;
if (!rangeSelector._valuesAssigned)
{
return;
}
var newValue = (double)e.NewValue;
rangeSelector.RangeMaxToStepFrequency();
if (rangeSelector._valuesAssigned)
{
if (newValue < rangeSelector.Minimum)
{
rangeSelector.RangeEnd = rangeSelector.Minimum;
}
else if (newValue > rangeSelector.Maximum)
{
rangeSelector.RangeEnd = rangeSelector.Maximum;
}
rangeSelector.SyncActiveRectangle();
// If the new max is less than the old minimum then move the minimum
if (newValue < rangeSelector.RangeStart)
{
rangeSelector.RangeStart = newValue;
}
}
rangeSelector.SyncThumbs();
}
}
}

Просмотреть файл

@ -4,11 +4,9 @@
using System;
using Windows.Foundation;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Shapes;
namespace Microsoft.Toolkit.Uwp.UI.Controls
@ -37,33 +35,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
private const double DefaultStepFrequency = 1;
private static readonly TimeSpan TimeToHideToolTipOnKeyUp = TimeSpan.FromSeconds(1);
/// <summary>
/// Identifies the Minimum dependency property.
/// </summary>
public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register(nameof(Minimum), typeof(double), typeof(RangeSelector), new PropertyMetadata(DefaultMinimum, MinimumChangedCallback));
/// <summary>
/// Identifies the Maximum dependency property.
/// </summary>
public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(nameof(Maximum), typeof(double), typeof(RangeSelector), new PropertyMetadata(DefaultMaximum, MaximumChangedCallback));
/// <summary>
/// Identifies the RangeMin dependency property.
/// </summary>
public static readonly DependencyProperty RangeMinProperty = DependencyProperty.Register(nameof(RangeMin), typeof(double), typeof(RangeSelector), new PropertyMetadata(DefaultMinimum, RangeMinChangedCallback));
/// <summary>
/// Identifies the RangeMax dependency property.
/// </summary>
public static readonly DependencyProperty RangeMaxProperty = DependencyProperty.Register(nameof(RangeMax), typeof(double), typeof(RangeSelector), new PropertyMetadata(DefaultMaximum, RangeMaxChangedCallback));
/// <summary>
/// Identifies the StepFrequency dependency property.
/// </summary>
public static readonly DependencyProperty StepFrequencyProperty = DependencyProperty.Register(nameof(StepFrequency), typeof(double), typeof(RangeSelector), new PropertyMetadata(DefaultStepFrequency));
private readonly DispatcherQueueTimer keyDebounceTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
private Border _outOfRangeContentContainer;
private Rectangle _activeRectangle;
private Thumb _minThumb;
@ -80,21 +51,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
private Grid _toolTip;
private TextBlock _toolTipText;
/// <summary>
/// Event raised when lower or upper range values are changed.
/// </summary>
public event EventHandler<RangeChangedEventArgs> ValueChanged;
/// <summary>
/// Event raised when lower or upper range thumbs start being dragged.
/// </summary>
public event DragStartedEventHandler ThumbDragStarted;
/// <summary>
/// Event raised when lower or upper range thumbs end being dragged.
/// </summary>
public event DragCompletedEventHandler ThumbDragCompleted;
/// <summary>
/// Initializes a new instance of the <see cref="RangeSelector"/> class.
/// Create a default range selector control.
@ -188,175 +144,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
base.OnApplyTemplate();
}
private void MinThumb_KeyDown(object sender, KeyRoutedEventArgs e)
private static void UpdateToolTipText(RangeSelector rangeSelector, TextBlock toolTip, double newValue)
{
switch (e.Key)
if (toolTip != null)
{
case VirtualKey.Left:
RangeMin -= StepFrequency;
SyncThumbs(fromMinKeyDown: true);
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Visible;
}
e.Handled = true;
break;
case VirtualKey.Right:
RangeMin += StepFrequency;
SyncThumbs(fromMinKeyDown: true);
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Visible;
}
e.Handled = true;
break;
toolTip.Text = string.Format("{0:0.##}", newValue);
}
}
private void MaxThumb_KeyDown(object sender, KeyRoutedEventArgs e)
{
switch (e.Key)
{
case VirtualKey.Left:
RangeMax -= StepFrequency;
SyncThumbs(fromMaxKeyDown: true);
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Visible;
}
e.Handled = true;
break;
case VirtualKey.Right:
RangeMax += StepFrequency;
SyncThumbs(fromMaxKeyDown: true);
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Visible;
}
e.Handled = true;
break;
}
}
private void Thumb_KeyUp(object sender, KeyRoutedEventArgs e)
{
switch (e.Key)
{
case VirtualKey.Left:
case VirtualKey.Right:
if (_toolTip != null)
{
keyDebounceTimer.Debounce(
() => _toolTip.Visibility = Visibility.Collapsed,
TimeToHideToolTipOnKeyUp);
}
e.Handled = true;
break;
}
}
private void ContainerCanvas_PointerEntered(object sender, PointerRoutedEventArgs e)
{
VisualStateManager.GoToState(this, "PointerOver", false);
}
private void ContainerCanvas_PointerExited(object sender, PointerRoutedEventArgs e)
{
var position = e.GetCurrentPoint(_containerCanvas).Position.X;
var normalizedPosition = ((position / DragWidth()) * (Maximum - Minimum)) + Minimum;
if (_pointerManipulatingMin)
{
_pointerManipulatingMin = false;
_containerCanvas.IsHitTestVisible = true;
ValueChanged?.Invoke(this, new RangeChangedEventArgs(RangeMin, normalizedPosition, RangeSelectorProperty.MinimumValue));
}
else if (_pointerManipulatingMax)
{
_pointerManipulatingMax = false;
_containerCanvas.IsHitTestVisible = true;
ValueChanged?.Invoke(this, new RangeChangedEventArgs(RangeMax, normalizedPosition, RangeSelectorProperty.MaximumValue));
}
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Collapsed;
}
VisualStateManager.GoToState(this, "Normal", false);
}
private void ContainerCanvas_PointerReleased(object sender, PointerRoutedEventArgs e)
{
var position = e.GetCurrentPoint(_containerCanvas).Position.X;
var normalizedPosition = ((position / DragWidth()) * (Maximum - Minimum)) + Minimum;
if (_pointerManipulatingMin)
{
_pointerManipulatingMin = false;
_containerCanvas.IsHitTestVisible = true;
ValueChanged?.Invoke(this, new RangeChangedEventArgs(RangeMin, normalizedPosition, RangeSelectorProperty.MinimumValue));
}
else if (_pointerManipulatingMax)
{
_pointerManipulatingMax = false;
_containerCanvas.IsHitTestVisible = true;
ValueChanged?.Invoke(this, new RangeChangedEventArgs(RangeMax, normalizedPosition, RangeSelectorProperty.MaximumValue));
}
SyncThumbs();
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Collapsed;
}
}
private void ContainerCanvas_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var position = e.GetCurrentPoint(_containerCanvas).Position.X;
var normalizedPosition = ((position / DragWidth()) * (Maximum - Minimum)) + Minimum;
if (_pointerManipulatingMin && normalizedPosition < RangeMax)
{
RangeMin = DragThumb(_minThumb, 0, Canvas.GetLeft(_maxThumb), position);
UpdateToolTipText(this, _toolTipText, RangeMin);
}
else if (_pointerManipulatingMax && normalizedPosition > RangeMin)
{
RangeMax = DragThumb(_maxThumb, Canvas.GetLeft(_minThumb), DragWidth(), position);
UpdateToolTipText(this, _toolTipText, RangeMax);
}
}
private void ContainerCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
{
var position = e.GetCurrentPoint(_containerCanvas).Position.X;
var normalizedPosition = position * Math.Abs(Maximum - Minimum) / DragWidth();
double upperValueDiff = Math.Abs(RangeMax - normalizedPosition);
double lowerValueDiff = Math.Abs(RangeMin - normalizedPosition);
if (upperValueDiff < lowerValueDiff)
{
RangeMax = normalizedPosition;
_pointerManipulatingMax = true;
Thumb_DragStarted(_maxThumb);
}
else
{
RangeMin = normalizedPosition;
_pointerManipulatingMin = true;
Thumb_DragStarted(_minThumb);
}
SyncThumbs();
}
private void ContainerCanvas_SizeChanged(object sender, SizeChangedEventArgs e)
{
SyncThumbs();
@ -377,301 +172,48 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
if (!_maxSet)
{
RangeMax = Maximum;
RangeEnd = Maximum;
}
if (!_minSet)
{
RangeMin = Minimum;
RangeStart = Minimum;
}
if (RangeMin < Minimum)
if (RangeStart < Minimum)
{
RangeMin = Minimum;
RangeStart = Minimum;
}
if (RangeMax < Minimum)
if (RangeEnd < Minimum)
{
RangeMax = Minimum;
RangeEnd = Minimum;
}
if (RangeMin > Maximum)
if (RangeStart > Maximum)
{
RangeMin = Maximum;
RangeStart = Maximum;
}
if (RangeMax > Maximum)
if (RangeEnd > Maximum)
{
RangeMax = Maximum;
RangeEnd = Maximum;
}
if (RangeMax < RangeMin)
if (RangeEnd < RangeStart)
{
RangeMin = RangeMax;
}
}
/// <summary>
/// Gets or sets the minimum value of the range.
/// </summary>
/// <value>
/// The minimum.
/// </value>
public double Minimum
{
get
{
return (double)GetValue(MinimumProperty);
}
set
{
SetValue(MinimumProperty, value);
}
}
private static void MinimumChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var rangeSelector = d as RangeSelector;
if (rangeSelector == null || !rangeSelector._valuesAssigned)
{
return;
}
var newValue = (double)e.NewValue;
var oldValue = (double)e.OldValue;
if (rangeSelector.Maximum < newValue)
{
rangeSelector.Maximum = newValue + Epsilon;
}
if (rangeSelector.RangeMin < newValue)
{
rangeSelector.RangeMin = newValue;
}
if (rangeSelector.RangeMax < newValue)
{
rangeSelector.RangeMax = newValue;
}
if (newValue != oldValue)
{
rangeSelector.SyncThumbs();
}
}
/// <summary>
/// Gets or sets the maximum value of the range.
/// </summary>
/// <value>
/// The maximum.
/// </value>
public double Maximum
{
get
{
return (double)GetValue(MaximumProperty);
}
set
{
SetValue(MaximumProperty, value);
}
}
private static void MaximumChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var rangeSelector = d as RangeSelector;
if (rangeSelector == null || !rangeSelector._valuesAssigned)
{
return;
}
var newValue = (double)e.NewValue;
var oldValue = (double)e.OldValue;
if (rangeSelector.Minimum > newValue)
{
rangeSelector.Minimum = newValue - Epsilon;
}
if (rangeSelector.RangeMax > newValue)
{
rangeSelector.RangeMax = newValue;
}
if (rangeSelector.RangeMin > newValue)
{
rangeSelector.RangeMin = newValue;
}
if (newValue != oldValue)
{
rangeSelector.SyncThumbs();
}
}
/// <summary>
/// Gets or sets the current lower limit value of the range.
/// </summary>
/// <value>
/// The current lower limit.
/// </value>
public double RangeMin
{
get
{
return (double)GetValue(RangeMinProperty);
}
set
{
SetValue(RangeMinProperty, value);
}
}
private static void RangeMinChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var rangeSelector = d as RangeSelector;
if (rangeSelector == null)
{
return;
}
rangeSelector._minSet = true;
if (!rangeSelector._valuesAssigned)
{
return;
}
var newValue = (double)e.NewValue;
rangeSelector.RangeMinToStepFrequency();
if (rangeSelector._valuesAssigned)
{
if (newValue < rangeSelector.Minimum)
{
rangeSelector.RangeMin = rangeSelector.Minimum;
}
else if (newValue > rangeSelector.Maximum)
{
rangeSelector.RangeMin = rangeSelector.Maximum;
}
rangeSelector.SyncActiveRectangle();
// If the new value is greater than the old max, move the max also
if (newValue > rangeSelector.RangeMax)
{
rangeSelector.RangeMax = newValue;
}
}
rangeSelector.SyncThumbs();
}
/// <summary>
/// Gets or sets the current upper limit value of the range.
/// </summary>
/// <value>
/// The current upper limit.
/// </value>
public double RangeMax
{
get
{
return (double)GetValue(RangeMaxProperty);
}
set
{
SetValue(RangeMaxProperty, value);
}
}
private static void RangeMaxChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var rangeSelector = d as RangeSelector;
if (rangeSelector == null)
{
return;
}
rangeSelector._maxSet = true;
if (!rangeSelector._valuesAssigned)
{
return;
}
var newValue = (double)e.NewValue;
rangeSelector.RangeMaxToStepFrequency();
if (rangeSelector._valuesAssigned)
{
if (newValue < rangeSelector.Minimum)
{
rangeSelector.RangeMax = rangeSelector.Minimum;
}
else if (newValue > rangeSelector.Maximum)
{
rangeSelector.RangeMax = rangeSelector.Maximum;
}
rangeSelector.SyncActiveRectangle();
// If the new max is less than the old minimum then move the minimum
if (newValue < rangeSelector.RangeMin)
{
rangeSelector.RangeMin = newValue;
}
}
rangeSelector.SyncThumbs();
}
private static void UpdateToolTipText(RangeSelector rangeSelector, TextBlock toolTip, double newValue)
{
if (toolTip != null)
{
toolTip.Text = string.Format("{0:0.##}", newValue);
}
}
/// <summary>
/// Gets or sets the value part of a value range that steps should be created for.
/// </summary>
/// <value>
/// The value part of a value range that steps should be created for.
/// </value>
public double StepFrequency
{
get
{
return (double)GetValue(StepFrequencyProperty);
}
set
{
SetValue(StepFrequencyProperty, value);
RangeStart = RangeEnd;
}
}
private void RangeMinToStepFrequency()
{
RangeMin = MoveToStepFrequency(RangeMin);
RangeStart = MoveToStepFrequency(RangeStart);
}
private void RangeMaxToStepFrequency()
{
RangeMax = MoveToStepFrequency(RangeMax);
RangeEnd = MoveToStepFrequency(RangeEnd);
}
private double MoveToStepFrequency(double rangeValue)
@ -699,8 +241,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
return;
}
var relativeLeft = ((RangeMin - Minimum) / (Maximum - Minimum)) * DragWidth();
var relativeRight = ((RangeMax - Minimum) / (Maximum - Minimum)) * DragWidth();
var relativeLeft = ((RangeStart - Minimum) / (Maximum - Minimum)) * DragWidth();
var relativeRight = ((RangeEnd - Minimum) / (Maximum - Minimum)) * DragWidth();
Canvas.SetLeft(_minThumb, relativeLeft);
Canvas.SetLeft(_maxThumb, relativeRight);
@ -714,7 +256,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
fromMinKeyDown ? relativeLeft : relativeRight);
if (_toolTipText != null)
{
UpdateToolTipText(this, _toolTipText, fromMinKeyDown ? RangeMin : RangeMax);
UpdateToolTipText(this, _toolTipText, fromMinKeyDown ? RangeStart : RangeEnd);
}
}
@ -744,104 +286,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
_activeRectangle.Width = Math.Max(0, Canvas.GetLeft(_maxThumb) - Canvas.GetLeft(_minThumb));
}
private double DragWidth()
{
return _containerCanvas.ActualWidth - _maxThumb.Width;
}
private void MinThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
_absolutePosition += e.HorizontalChange;
RangeMin = DragThumb(_minThumb, 0, Canvas.GetLeft(_maxThumb), _absolutePosition);
if (_toolTipText != null)
{
UpdateToolTipText(this, _toolTipText, RangeMin);
}
}
private void MaxThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
_absolutePosition += e.HorizontalChange;
RangeMax = DragThumb(_maxThumb, Canvas.GetLeft(_minThumb), DragWidth(), _absolutePosition);
if (_toolTipText != null)
{
UpdateToolTipText(this, _toolTipText, RangeMax);
}
}
private double DragThumb(Thumb thumb, double min, double max, double nextPos)
{
nextPos = Math.Max(min, nextPos);
nextPos = Math.Min(max, nextPos);
Canvas.SetLeft(thumb, nextPos);
if (_toolTipText != null && _toolTip != null)
{
var thumbCenter = nextPos + (thumb.Width / 2);
_toolTip.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
var ttWidth = _toolTip.ActualWidth / 2;
Canvas.SetLeft(_toolTip, thumbCenter - ttWidth);
}
return Minimum + ((nextPos / DragWidth()) * (Maximum - Minimum));
}
private void Thumb_DragStarted(Thumb thumb)
{
var useMin = thumb == _minThumb;
var otherThumb = useMin ? _maxThumb : _minThumb;
_absolutePosition = Canvas.GetLeft(thumb);
Canvas.SetZIndex(thumb, 10);
Canvas.SetZIndex(otherThumb, 0);
_oldValue = RangeMin;
if (_toolTipText != null && _toolTip != null)
{
_toolTip.Visibility = Visibility.Visible;
var thumbCenter = _absolutePosition + (thumb.Width / 2);
_toolTip.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
var ttWidth = _toolTip.ActualWidth / 2;
Canvas.SetLeft(_toolTip, thumbCenter - ttWidth);
UpdateToolTipText(this, _toolTipText, useMin ? RangeMin : RangeMax);
}
VisualStateManager.GoToState(this, useMin ? "MinPressed" : "MaxPressed", true);
}
private void MinThumb_DragStarted(object sender, DragStartedEventArgs e)
{
ThumbDragStarted?.Invoke(this, e);
Thumb_DragStarted(_minThumb);
}
private void MaxThumb_DragStarted(object sender, DragStartedEventArgs e)
{
ThumbDragStarted?.Invoke(this, e);
Thumb_DragStarted(_maxThumb);
}
private void Thumb_DragCompleted(object sender, DragCompletedEventArgs e)
{
ThumbDragCompleted?.Invoke(this, e);
ValueChanged?.Invoke(this, sender.Equals(_minThumb) ? new RangeChangedEventArgs(_oldValue, RangeMin, RangeSelectorProperty.MinimumValue) : new RangeChangedEventArgs(_oldValue, RangeMax, RangeSelectorProperty.MaximumValue));
SyncThumbs();
if (_toolTip != null)
{
_toolTip.Visibility = Visibility.Collapsed;
}
VisualStateManager.GoToState(this, "Normal", true);
}
private void RangeSelector_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
{
VisualStateManager.GoToState(this, IsEnabled ? "Normal" : "Disabled", true);

Просмотреть файл

@ -5,7 +5,7 @@
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.DataTransfer;
using Windows.UI.Core;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
@ -136,28 +136,30 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
internal void SelectAllTokensAndText()
{
_ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
this.SelectAllSafe();
// need to synchronize the select all and the focus behavior on the text box
// because there is no way to identify that the focus has been set from this point
// to avoid instantly clearing the selection of tokens
PauseTokenClearOnFocus = true;
foreach (var item in Items)
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
_ = dispatcherQueue.EnqueueAsync(
() =>
{
if (item is ITokenStringContainer)
{
// grab any selected text
var pretoken = ContainerFromItem(item) as TokenizingTextBoxItem;
pretoken._autoSuggestTextBox.SelectionStart = 0;
pretoken._autoSuggestTextBox.SelectionLength = pretoken._autoSuggestTextBox.Text.Length;
}
}
this.SelectAllSafe();
(ContainerFromIndex(Items.Count - 1) as TokenizingTextBoxItem).Focus(FocusState.Programmatic);
});
// need to synchronize the select all and the focus behavior on the text box
// because there is no way to identify that the focus has been set from this point
// to avoid instantly clearing the selection of tokens
PauseTokenClearOnFocus = true;
foreach (var item in Items)
{
if (item is ITokenStringContainer)
{
// grab any selected text
var pretoken = ContainerFromItem(item) as TokenizingTextBoxItem;
pretoken._autoSuggestTextBox.SelectionStart = 0;
pretoken._autoSuggestTextBox.SelectionLength = pretoken._autoSuggestTextBox.Text.Length;
}
}
(ContainerFromIndex(Items.Count - 1) as TokenizingTextBoxItem).Focus(FocusState.Programmatic);
}, DispatcherQueuePriority.Normal);
}
internal void DeselectAllTokensAndText(TokenizingTextBoxItem ignoreItem = null)

Просмотреть файл

@ -224,54 +224,57 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
await RemoveAllSelectedTokens();
// Wait for removal of old items
_ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
// If we're before the last textbox and it's empty, redirect focus to that one instead
if (index == _innerItemsSource.Count - 1 && string.IsNullOrWhiteSpace(_lastTextEdit.Text))
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
_ = dispatcherQueue.EnqueueAsync(
() =>
{
var lastContainer = ContainerFromItem(_lastTextEdit) as TokenizingTextBoxItem;
lastContainer.UseCharacterAsUser = true; // Make sure we trigger a refresh of suggested items.
_lastTextEdit.Text = string.Empty + args.Character;
UpdateCurrentTextEdit(_lastTextEdit);
lastContainer._autoSuggestTextBox.SelectionStart = 1; // Set position to after our new character inserted
lastContainer._autoSuggestTextBox.Focus(FocusState.Keyboard);
}
else
{
//// Otherwise, create a new textbox for this text.
UpdateCurrentTextEdit(new PretokenStringContainer((string.Empty + args.Character).Trim())); // Trim so that 'space' isn't inserted and can be used to insert a new box.
_innerItemsSource.Insert(index, _currentTextEdit);
// Need to wait for containerization
_ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
// If we're before the last textbox and it's empty, redirect focus to that one instead
if (index == _innerItemsSource.Count - 1 && string.IsNullOrWhiteSpace(_lastTextEdit.Text))
{
var newContainer = ContainerFromIndex(index) as TokenizingTextBoxItem; // Should be our last text box
var lastContainer = ContainerFromItem(_lastTextEdit) as TokenizingTextBoxItem;
newContainer.UseCharacterAsUser = true; // Make sure we trigger a refresh of suggested items.
lastContainer.UseCharacterAsUser = true; // Make sure we trigger a refresh of suggested items.
void WaitForLoad(object s, RoutedEventArgs eargs)
{
if (newContainer._autoSuggestTextBox != null)
_lastTextEdit.Text = string.Empty + args.Character;
UpdateCurrentTextEdit(_lastTextEdit);
lastContainer._autoSuggestTextBox.SelectionStart = 1; // Set position to after our new character inserted
lastContainer._autoSuggestTextBox.Focus(FocusState.Keyboard);
}
else
{
//// Otherwise, create a new textbox for this text.
UpdateCurrentTextEdit(new PretokenStringContainer((string.Empty + args.Character).Trim())); // Trim so that 'space' isn't inserted and can be used to insert a new box.
_innerItemsSource.Insert(index, _currentTextEdit);
// Need to wait for containerization
_ = dispatcherQueue.EnqueueAsync(
() =>
{
newContainer._autoSuggestTextBox.SelectionStart = 1; // Set position to after our new character inserted
var newContainer = ContainerFromIndex(index) as TokenizingTextBoxItem; // Should be our last text box
newContainer._autoSuggestTextBox.Focus(FocusState.Keyboard);
}
newContainer.UseCharacterAsUser = true; // Make sure we trigger a refresh of suggested items.
newContainer.Loaded -= WaitForLoad;
}
void WaitForLoad(object s, RoutedEventArgs eargs)
{
if (newContainer._autoSuggestTextBox != null)
{
newContainer._autoSuggestTextBox.SelectionStart = 1; // Set position to after our new character inserted
newContainer.AutoSuggestTextBoxLoaded += WaitForLoad;
});
}
});
newContainer._autoSuggestTextBox.Focus(FocusState.Keyboard);
}
newContainer.Loaded -= WaitForLoad;
}
newContainer.AutoSuggestTextBoxLoaded += WaitForLoad;
}, DispatcherQueuePriority.Normal);
}
}, DispatcherQueuePriority.Normal);
}
else
{

Просмотреть файл

@ -93,28 +93,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Automation.Peers
return string.Empty;
}
/// <summary>
/// Called by GetAutomationId that gets the **AutomationId** of the element that is associated with the automation peer.
/// </summary>
/// <returns>
/// The string that contains the automation ID.
/// </returns>
protected override string GetAutomationIdCore()
{
string automationId = base.GetAutomationIdCore();
if (!string.IsNullOrEmpty(automationId))
{
return automationId;
}
if (this.OwnerBladeItem != null)
{
return this.GetNameCore();
}
return string.Empty;
}
/// <summary>
/// Returns the size of the set where the element that is associated with the automation peer is located.
/// </summary>

Просмотреть файл

@ -9,7 +9,7 @@ using System.Linq;
using Microsoft.Toolkit.Uwp.UI.Automation.Peers;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Core;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Automation.Peers;
using Windows.UI.Xaml.Controls;
@ -153,10 +153,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
UpdateLayout();
// Need to do this because of touch. See more information here: https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/760#issuecomment-276466464
await Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
{
GetScrollViewer()?.ChangeView(_scrollViewer.ScrollableWidth, null, null);
});
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
await dispatcherQueue.EnqueueAsync(
() =>
{
GetScrollViewer()?.ChangeView(_scrollViewer.ScrollableWidth, null, null);
}, DispatcherQueuePriority.Low);
return;
}

Просмотреть файл

@ -5,9 +5,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Toolkit.Uwp.UI.Automation.Peers;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Automation;
using Windows.UI.Xaml.Automation.Peers;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
@ -520,6 +522,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
{
carouselItem.IsSelected = true;
}
carouselItem.ParentCarousel = this;
}
/// <summary>
/// Creates AutomationPeer (<see cref="UIElement.OnCreateAutomationPeer"/>)
/// </summary>
/// <returns>An automation peer for this <see cref="Carousel"/>.</returns>
protected override AutomationPeer OnCreateAutomationPeer()
{
return new CarouselAutomationPeer(this);
}
private void OnCarouselItemSelected(object sender, EventArgs e)
@ -528,5 +541,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
SelectedItem = ItemFromContainer(item);
}
internal void SetSelectedItem(CarouselItem owner)
{
var item = ItemFromContainer(owner);
SelectedItem = item;
}
}
}

Просмотреть файл

@ -0,0 +1,143 @@
// 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.Collections.Generic;
using Microsoft.Toolkit.Uwp.UI.Controls;
using Windows.UI.Xaml.Automation;
using Windows.UI.Xaml.Automation.Peers;
using Windows.UI.Xaml.Automation.Provider;
using Windows.UI.Xaml.Controls;
namespace Microsoft.Toolkit.Uwp.UI.Automation.Peers
{
/// <summary>
/// Defines a framework element automation peer for the <see cref="Carousel"/> control.
/// </summary>
public class CarouselAutomationPeer : ItemsControlAutomationPeer, ISelectionProvider
{
/// <summary>
/// Initializes a new instance of the <see cref="CarouselAutomationPeer"/> class.
/// </summary>
/// <param name="owner">
/// The <see cref="Carousel" /> that is associated with this <see cref="T:Windows.UI.Xaml.Automation.Peers.CarouselAutomationPeer" />.
/// </param>
public CarouselAutomationPeer(Carousel owner)
: base(owner)
{
}
/// <summary>Gets a value indicating whether the Microsoft UI Automation provider allows more than one child element to be selected concurrently.</summary>
/// <returns>True if multiple selection is allowed; otherwise, false.</returns>
public bool CanSelectMultiple => false;
/// <summary>Gets a value indicating whether the UI Automation provider requires at least one child element to be selected.</summary>
/// <returns>True if selection is required; otherwise, false.</returns>
public bool IsSelectionRequired => true;
private Carousel OwningCarousel
{
get
{
return Owner as Carousel;
}
}
/// <summary>Retrieves a UI Automation provider for each child element that is selected.</summary>
/// <returns>An array of UI Automation providers.</returns>
public IRawElementProviderSimple[] GetSelection()
{
return OwningCarousel.ContainerFromItem(this.OwningCarousel.SelectedItem) is CarouselItem selectedCarouselItem
? new[] { this.ProviderFromPeer(FromElement(selectedCarouselItem)) }
: new IRawElementProviderSimple[] { };
}
/// <summary>
/// Gets the control type for the element that is associated with the UI Automation peer.
/// </summary>
/// <returns>The control type.</returns>
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.List;
}
/// <summary>
/// Called by GetClassName that gets a human readable name that, in addition to AutomationControlType,
/// differentiates the control represented by this AutomationPeer.
/// </summary>
/// <returns>The string that contains the name.</returns>
protected override string GetClassNameCore()
{
return Owner.GetType().Name;
}
/// <summary>
/// Called by GetName.
/// </summary>
/// <returns>
/// Returns the first of these that is not null or empty:
/// - Value returned by the base implementation
/// - Name of the owning Carousel
/// - Carousel class name
/// </returns>
protected override string GetNameCore()
{
string name = this.OwningCarousel.Name;
if (!string.IsNullOrEmpty(name))
{
return name;
}
name = AutomationProperties.GetName(this.OwningCarousel);
if (!string.IsNullOrEmpty(name))
{
return name;
}
return base.GetNameCore();
}
/// <summary>
/// Gets the control pattern that is associated with the specified Windows.UI.Xaml.Automation.Peers.PatternInterface.
/// </summary>
/// <param name="patternInterface">A value from the Windows.UI.Xaml.Automation.Peers.PatternInterface enumeration.</param>
/// <returns>The object that supports the specified pattern, or null if unsupported.</returns>
protected override object GetPatternCore(PatternInterface patternInterface)
{
switch (patternInterface)
{
case PatternInterface.Selection:
return this;
}
return base.GetPatternCore(patternInterface);
}
/// <summary>
/// Gets the collection of elements that are represented in the UI Automation tree as immediate
/// child elements of the automation peer.
/// </summary>
/// <returns>The children elements.</returns>
protected override IList<AutomationPeer> GetChildrenCore()
{
Carousel owner = OwningCarousel;
ItemCollection items = owner.Items;
if (items.Count <= 0)
{
return null;
}
List<AutomationPeer> peers = new List<AutomationPeer>(items.Count);
for (int i = 0; i < items.Count; i++)
{
if (owner.ContainerFromIndex(i) is CarouselItem element)
{
peers.Add(FromElement(element) ?? CreatePeerForElement(element));
}
}
return peers;
}
}
}

Просмотреть файл

@ -3,8 +3,9 @@
// See the LICENSE file in the project root for more information.
using System;
using Microsoft.Toolkit.Uwp.UI.Automation.Peers;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Automation.Peers;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Input;
@ -22,6 +23,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
private const string SelectedState = "Selected";
private const string NormalState = "Normal";
private WeakReference<Carousel> parentCarousel;
/// <summary>
/// Initializes a new instance of the <see cref="CarouselItem"/> class.
/// </summary>
@ -33,6 +36,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
RegisterPropertyChangedCallback(SelectorItem.IsSelectedProperty, OnIsSelectedChanged);
}
internal Carousel ParentCarousel
{
get
{
this.parentCarousel.TryGetTarget(out var carousel);
return carousel;
}
set => this.parentCarousel = new WeakReference<Carousel>(value);
}
/// <inheritdoc/>
protected override void OnPointerEntered(PointerRoutedEventArgs e)
{
@ -57,6 +70,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
VisualStateManager.GoToState(this, IsSelected ? PressedSelectedState : PressedState, true);
}
/// <summary>
/// Creates AutomationPeer (<see cref="UIElement.OnCreateAutomationPeer"/>)
/// </summary>
/// <returns>An automation peer for this <see cref="CarouselItem"/>.</returns>
protected override AutomationPeer OnCreateAutomationPeer()
{
return new CarouselItemAutomationPeer(this);
}
internal event EventHandler Selected;
private void OnIsSelectedChanged(DependencyObject sender, DependencyProperty dp)

Просмотреть файл

@ -0,0 +1,188 @@
// 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 Microsoft.Toolkit.Uwp.UI.Controls;
using Windows.UI.Xaml.Automation;
using Windows.UI.Xaml.Automation.Peers;
using Windows.UI.Xaml.Automation.Provider;
using Windows.UI.Xaml.Controls;
namespace Microsoft.Toolkit.Uwp.UI.Automation.Peers
{
/// <summary>
/// Defines a framework element automation peer for the <see cref="CarouselItem"/>.
/// </summary>
public class CarouselItemAutomationPeer : FrameworkElementAutomationPeer, ISelectionItemProvider
{
/// <summary>
/// Initializes a new instance of the <see cref="CarouselItemAutomationPeer"/> class.
/// </summary>
/// <param name="owner">
/// The <see cref="CarouselItem" /> that is associated with this <see cref="T:Windows.UI.Xaml.Automation.Peers.CarouselItemAutomationPeer" />.
/// </param>
public CarouselItemAutomationPeer(CarouselItem owner)
: base(owner)
{
}
/// <summary>Gets a value indicating whether an item is selected.</summary>
/// <returns>True if the element is selected; otherwise, false.</returns>
public bool IsSelected => this.OwnerCarouselItem.IsSelected;
/// <summary>Gets the UI Automation provider that implements ISelectionProvider and acts as the container for the calling object.</summary>
/// <returns>The UI Automation provider.</returns>
public IRawElementProviderSimple SelectionContainer
{
get
{
Carousel parent = this.OwnerCarouselItem.ParentCarousel;
if (parent == null)
{
return null;
}
AutomationPeer peer = FromElement(parent);
return peer != null ? this.ProviderFromPeer(peer) : null;
}
}
private CarouselItem OwnerCarouselItem
{
get { return this.Owner as CarouselItem; }
}
/// <summary>Adds the current element to the collection of selected items.</summary>
public void AddToSelection()
{
CarouselItem owner = this.OwnerCarouselItem;
Carousel parent = owner.ParentCarousel;
parent?.SetSelectedItem(owner);
}
/// <summary>Removes the current element from the collection of selected items.</summary>
public void RemoveFromSelection()
{
// Cannot remove the selection of a Carousel control.
}
/// <summary>Clears any existing selection and then selects the current element.</summary>
public void Select()
{
CarouselItem owner = this.OwnerCarouselItem;
Carousel parent = owner.ParentCarousel;
parent?.SetSelectedItem(owner);
}
/// <summary>
/// Gets the control type for the element that is associated with the UI Automation peer.
/// </summary>
/// <returns>The control type.</returns>
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.ListItem;
}
/// <summary>
/// Called by GetClassName that gets a human readable name that, in addition to AutomationControlType,
/// differentiates the control represented by this AutomationPeer.
/// </summary>
/// <returns>The string that contains the name.</returns>
protected override string GetClassNameCore()
{
return Owner.GetType().Name;
}
/// <summary>
/// Called by GetName.
/// </summary>
/// <returns>
/// Returns the first of these that is not null or empty:
/// - Value returned by the base implementation
/// - Name of the owning CarouselItem
/// - Carousel class name
/// </returns>
protected override string GetNameCore()
{
string name = AutomationProperties.GetName(this.OwnerCarouselItem);
if (!string.IsNullOrEmpty(name))
{
return name;
}
name = this.OwnerCarouselItem.Name;
if (!string.IsNullOrEmpty(name))
{
return name;
}
var textBlock = this.OwnerCarouselItem.FindDescendant<TextBlock>();
if (textBlock != null)
{
return textBlock.Text;
}
return base.GetNameCore();
}
/// <summary>
/// Gets the control pattern that is associated with the specified Windows.UI.Xaml.Automation.Peers.PatternInterface.
/// </summary>
/// <param name="patternInterface">A value from the Windows.UI.Xaml.Automation.Peers.PatternInterface enumeration.</param>
/// <returns>The object that supports the specified pattern, or null if unsupported.</returns>
protected override object GetPatternCore(PatternInterface patternInterface)
{
switch (patternInterface)
{
case PatternInterface.SelectionItem:
return this;
}
return base.GetPatternCore(patternInterface);
}
/// <summary>
/// Returns the size of the set where the element that is associated with the automation peer is located.
/// </summary>
/// <returns>
/// The size of the set.
/// </returns>
protected override int GetSizeOfSetCore()
{
int sizeOfSet = base.GetSizeOfSetCore();
if (sizeOfSet != -1)
{
return sizeOfSet;
}
CarouselItem owner = this.OwnerCarouselItem;
Carousel parent = owner.ParentCarousel;
sizeOfSet = parent.Items.Count;
return sizeOfSet;
}
/// <summary>
/// Returns the ordinal position in the set for the element that is associated with the automation peer.
/// </summary>
/// <returns>
/// The ordinal position in the set.
/// </returns>
protected override int GetPositionInSetCore()
{
int positionInSet = base.GetPositionInSetCore();
if (positionInSet != -1)
{
return positionInSet;
}
CarouselItem owner = this.OwnerCarouselItem;
Carousel parent = owner.ParentCarousel;
positionInSet = parent.IndexFromContainer(owner) + 1;
return positionInSet;
}
}
}

Просмотреть файл

@ -61,6 +61,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
Foreground = GripperForeground,
Text = _resizeDirection == GridResizeDirection.Columns ? GripperBarVertical : GripperBarHorizontal
};
_gripperDisplay.SetValue(
Windows.UI.Xaml.Automation.AutomationProperties.AccessibilityViewProperty,
Windows.UI.Xaml.Automation.Peers.AccessibilityView.Raw);
}
}

Просмотреть файл

@ -33,6 +33,10 @@
<None Include="$(OutDir)\Design\$(MSBuildProjectName).Design*.dll;$(OutDir)\Design\$(MSBuildProjectName).Design*.pdb" Pack="true" PackagePath="lib\$(TargetFramework)\Design" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.UI.Xaml" Version="2.5.0" />
</ItemGroup>
<ItemGroup>
<PRIResource Include="Strings\en-us\Resources.resw" />
</ItemGroup>

Просмотреть файл

@ -10,7 +10,7 @@ using System.Threading.Tasks;
using ColorCode;
using Microsoft.Toolkit.Parsers.Markdown;
using Microsoft.Toolkit.Uwp.UI.Controls.Markdown.Render;
using Windows.UI.Core;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Documents;
@ -347,7 +347,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
}
multiClickDetectionTriggered = true;
await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => multiClickDetectionTriggered = false);
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
await dispatcherQueue.EnqueueAsync(() => multiClickDetectionTriggered = false, DispatcherQueuePriority.High);
// Get the hyperlink URL.
if (url == null)

Просмотреть файл

@ -19,6 +19,7 @@
<ItemGroup>
<PackageReference Include="ColorCode.UWP" Version="2.0.6" />
<PackageReference Include="Microsoft.UI.Xaml" Version="2.5.0" />
<ProjectReference Include="..\Microsoft.Toolkit.Uwp.UI.Controls.Core\Microsoft.Toolkit.Uwp.UI.Controls.Core.csproj" />
<ProjectReference Include="..\Microsoft.Toolkit.Uwp.UI\Microsoft.Toolkit.Uwp.UI.csproj" />
</ItemGroup>

Просмотреть файл

@ -18,6 +18,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.UI.Xaml" Version="2.5.0" />
<PackageReference Include="System.Text.Json" Version="4.7.2" />
<PackageReference Include="Win2D.uwp" Version="1.25.0" />
</ItemGroup>

Просмотреть файл

@ -14,13 +14,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
[ContentProperty(Name = nameof(Content))]
public partial class Case : DependencyObject
{
internal SwitchPresenter Parent { get; set; } // TODO: Can we remove Parent need here and just use events?
/// <summary>
/// Event raised when the <see cref="Value"/> property changes.
/// </summary>
public event EventHandler ValueChanged;
/// <summary>
/// Gets or sets the Content to display when this case is active.
/// </summary>
@ -64,14 +57,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// Identifies the <see cref="Value"/> property.
/// </summary>
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register(nameof(Value), typeof(object), typeof(Case), new PropertyMetadata(null, OnValuePropertyChanged));
private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var xcase = (Case)d;
xcase.ValueChanged?.Invoke(xcase, EventArgs.Empty);
}
DependencyProperty.Register(nameof(Value), typeof(object), typeof(Case), new PropertyMetadata(null));
/// <summary>
/// Initializes a new instance of the <see cref="Case"/> class.

Просмотреть файл

@ -5,130 +5,20 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Windows.UI.Xaml;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// An collection of <see cref="Case"/> to help with XAML interop.
/// </summary>
public class CaseCollection : IList<Case>, IEnumerable<Case> // TODO: Do we need this or can we use an ObservableCollection directly??? (Or is it useful to have it manage the registration of the child events?)
public class CaseCollection : DependencyObjectCollection
{
internal SwitchPresenter Parent { get; set; } // TODO: Can we remove Parent need here and just use events?
private readonly List<Case> _internalList = new List<Case>();
/// <inheritdoc/>
public int Count => _internalList.Count;
/// <inheritdoc/>
public bool IsReadOnly => false;
/// <inheritdoc/>
public Case this[int index] { get => _internalList[index]; set => Insert(index, value); }
/// <summary>
/// Raised when an animation has been added/removed or modified
/// </summary>
public event EventHandler CaseCollectionChanged;
private void ValueChanged(object sender, EventArgs e)
{
CaseCollectionChanged?.Invoke(this, EventArgs.Empty);
}
/// <summary>
/// Initializes a new instance of the <see cref="CaseCollection"/> class.
/// </summary>
public CaseCollection()
{
}
/// <inheritdoc/>
public int IndexOf(Case item)
{
return _internalList.IndexOf(item);
}
/// <inheritdoc/>
public void Insert(int index, Case item)
{
item.ValueChanged += ValueChanged;
item.Parent = Parent;
_internalList.Insert(index, item);
CaseCollectionChanged?.Invoke(this, EventArgs.Empty);
}
/// <inheritdoc/>
public void RemoveAt(int index)
{
if (index >= 0 && index < _internalList.Count)
{
var xcase = _internalList[index];
xcase.ValueChanged -= ValueChanged;
xcase.Parent = null;
}
_internalList.RemoveAt(index);
CaseCollectionChanged?.Invoke(this, EventArgs.Empty);
}
/// <inheritdoc/>
public void Add(Case item)
{
item.ValueChanged += ValueChanged;
item.Parent = Parent;
_internalList.Add(item);
CaseCollectionChanged?.Invoke(this, EventArgs.Empty);
}
/// <inheritdoc/>
public void Clear()
{
foreach (var xcase in _internalList)
{
xcase.ValueChanged -= ValueChanged;
xcase.Parent = null;
}
_internalList.Clear();
CaseCollectionChanged?.Invoke(this, EventArgs.Empty);
}
/// <inheritdoc/>
public bool Contains(Case item)
{
return _internalList.Contains(item);
}
/// <inheritdoc/>
public void CopyTo(Case[] array, int arrayIndex)
{
_internalList.CopyTo(array, arrayIndex);
}
/// <inheritdoc/>
public bool Remove(Case item)
{
var result = _internalList.Remove(item);
if (result)
{
item.ValueChanged -= ValueChanged;
item.Parent = null;
CaseCollectionChanged?.Invoke(this, EventArgs.Empty);
}
return result;
}
/// <inheritdoc/>
public IEnumerator<Case> GetEnumerator()
{
return _internalList.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return _internalList.GetEnumerator();
}
}
}

Просмотреть файл

@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.ComponentModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Markup;
@ -45,7 +46,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// Indicates the <see cref="SwitchCases"/> property.
/// </summary>
public static readonly DependencyProperty SwitchCasesProperty =
DependencyProperty.Register(nameof(SwitchCases), typeof(CaseCollection), typeof(SwitchPresenter), new PropertyMetadata(null, new PropertyChangedCallback(OnSwitchCasesPropertyChanged)));
DependencyProperty.Register(nameof(SwitchCases), typeof(CaseCollection), typeof(SwitchPresenter), new PropertyMetadata(null));
/// <summary>
/// Gets or sets a value indicating the value to compare all cases against. When this value is bound to and changes, the presenter will automatically evaluate cases and select the new appropriate content from the switch.
@ -60,48 +61,23 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// Indicates the <see cref="Value"/> property.
/// </summary>
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register(nameof(Value), typeof(object), typeof(SwitchPresenter), new PropertyMetadata(null, new PropertyChangedCallback(OnValuePropertyChanged)));
DependencyProperty.Register(nameof(Value), typeof(object), typeof(SwitchPresenter), new PropertyMetadata(null, OnValuePropertyChanged));
/// <summary>
/// Gets or sets a value indicating which type to first cast and compare provided values against.
/// </summary>
public Type TargetType
{
get { return (Type)GetValue(DataTypeProperty); }
set { SetValue(DataTypeProperty, value); }
get { return (Type)GetValue(TargetTypeProperty); }
set { SetValue(TargetTypeProperty, value); }
}
/// <summary>
/// Indicates the <see cref="TargetType"/> property.
/// </summary>
public static readonly DependencyProperty DataTypeProperty =
public static readonly DependencyProperty TargetTypeProperty =
DependencyProperty.Register(nameof(TargetType), typeof(Type), typeof(SwitchPresenter), new PropertyMetadata(null));
/// <summary>
/// Gets or sets a value indicating whether the content is removed from the visual tree when switching between cases.
/// </summary>
public bool IsVisualTreeDisconnectedOnChange { get; set; }
private static void OnSwitchCasesPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (e.OldValue != null)
{
((SwitchPresenter)e.OldValue).SwitchCases.CaseCollectionChanged -= OnCaseValuePropertyChanged;
}
var xswitch = (SwitchPresenter)d;
foreach (var xcase in xswitch.SwitchCases)
{
// Set our parent
xcase.Parent = xswitch;
}
// Will trigger on collection change and case value changed
xswitch.SwitchCases.Parent = xswitch;
xswitch.SwitchCases.CaseCollectionChanged += OnCaseValuePropertyChanged;
}
private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
// When our Switch's expression changes, re-evaluate.
@ -110,14 +86,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
xswitch.EvaluateCases();
}
private static void OnCaseValuePropertyChanged(object sender, EventArgs e)
{
// When something about our collection of cases changes, re-evaluate.
var collection = (CaseCollection)sender;
collection.Parent.EvaluateCases();
}
/// <summary>
/// Initializes a new instance of the <see cref="SwitchPresenter"/> class.
/// </summary>
@ -148,7 +116,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
Case xdefault = null;
Case newcase = null;
foreach (var xcase in SwitchCases)
foreach (Case xcase in SwitchCases)
{
if (xcase.IsDefault)
{
@ -170,19 +138,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
newcase = xdefault;
}
// Only bother changing things around if we have a new case.
// Only bother changing things around if we actually have a new case.
if (newcase != CurrentCase)
{
// Disconnect old content from visual tree.
if (CurrentCase != null && CurrentCase.Content != null && IsVisualTreeDisconnectedOnChange)
{
// TODO: If we disconnect here, we need to recreate later??? Need to Test...
VisualTreeHelper.DisconnectChildrenRecursive(CurrentCase.Content);
}
// Hookup new content.
Content = newcase.Content;
// If we don't have any cases or default, setting these to null is what we want to be blank again.
Content = newcase?.Content;
CurrentCase = newcase;
}
}
@ -237,6 +197,20 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
{
return value;
}
else if (targetType.IsEnum && value is string str)
{
if (Enum.TryParse(targetType, str, out object result))
{
return result;
}
static object ThrowExceptionForKeyNotFound()
{
throw new InvalidOperationException("The requested enum value was not present in the provided type.");
}
return ThrowExceptionForKeyNotFound();
}
else
{
return XamlBindingHelper.ConvertValue(targetType, value);

Просмотреть файл

@ -1,11 +1,17 @@
<Project Sdk="MSBuild.Sdk.Extras">
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<TargetFrameworks>uap10.0.17763</TargetFrameworks>
<Title>Windows Community Toolkit Controls</Title>
<Description>
This library provides Controls, Panels, ItemsRepeater Layouts, and various other classes &amp; helpers for XAML UI development with UWP. It is part of the Windows Community Toolkit.
This package provides no actual code and is only an aggregate of its dependencies. You can find out how to optimize your app after development at https://aka.ms/wct/optimize
</Description>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)readme.txt" Pack="true" PackagePath="\"/>
<ProjectReference Include="..\Microsoft.Toolkit.Uwp.UI.Controls.Primitives\Microsoft.Toolkit.Uwp.UI.Controls.Primitives.csproj" />
<ProjectReference Include="..\Microsoft.Toolkit.Uwp.UI.Controls.Core\Microsoft.Toolkit.Uwp.UI.Controls.Core.csproj" />
<ProjectReference Include="..\Microsoft.Toolkit.Uwp.UI.Controls.Media\Microsoft.Toolkit.Uwp.UI.Controls.Media.csproj" />

Просмотреть файл

@ -0,0 +1,42 @@
Thanks for installing the Windows Community Toolkit Controls NuGet package!
This is a meta-package made up of various Windows Community Toolkit packages.
It is for your ease and convenience to use all of the controls available!
You also have the option to only use packages you need which can help optimize the
size of your application once you are ready to ship. Visit https://aka.ms/wct/optimize to learn more.
You can find out more about the Windows Community Toolkit at https://aka.ms/windowstoolkit
Or even try our controls in our sample app at https://aka.ms/windowstoolkitapp
Docs are available here: https://aka.ms/windowstoolkitdocs
The Windows Community Toolkit is made possible by our developer community!
Every contribution made to the Toolkit helps everyone, to learn how to contribute visit https://aka.ms/wct/wiki
----
This package also depends on the WinUI library, so you'll need to set XamlControlsResources as your Application resources in App.xaml:
<Application>
<Application.Resources>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
</Application.Resources>
</Application>
If you have other resources, then we recommend you add those to the XamlControlsResources' MergedDictionaries.
This works with the platform's resource system to allow overrides of the XamlControlsResources resources.
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.UI.Xaml.Controls">
<Application.Resources>
<controls:XamlControlsResources>
<controls:XamlControlsResources.MergedDictionaries>
<!-- Other app resources here -->
</controls:XamlControlsResources.MergedDictionaries>
</controls:XamlControlsResources>
</Application.Resources>
</Application>
See http://aka.ms/winui for more information about the WinUI library.

Просмотреть файл

@ -70,7 +70,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
explicitTarget,
Delay ?? delayHint ?? DefaultDelay,
Duration ?? durationHint ?? DefaultDuration,
Repeat);
Repeat,
DelayBehavior);
AppendToBuilder(keyFrameBuilder, easingTypeHint, easingModeHint);

Просмотреть файл

@ -6,6 +6,7 @@ using System;
using System.Diagnostics.Contracts;
using System.Threading.Tasks;
using Microsoft.Toolkit.Uwp.UI.Media.Pipelines;
using Windows.System;
namespace Microsoft.Toolkit.Uwp.UI.Media
{
@ -79,20 +80,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Media
protected override PipelineBuilder OnPipelineRequested() => this.Pipeline;
/// <summary>
/// Clones the current instance by rebuilding the source <see cref="Windows.UI.Xaml.Media.Brush"/>. Use this method to reuse the same effects pipeline on a different <see cref="Windows.UI.Core.CoreDispatcher"/>
/// Clones the current instance by rebuilding the source <see cref="Windows.UI.Xaml.Media.Brush"/>. Use this method to reuse the same effects pipeline on a different <see cref="DispatcherQueue"/>
/// </summary>
/// <remarks>
/// If your code is already on the same thread, you can just assign this brush to an arbitrary number of controls and it will still work correctly.
/// This method is only meant to be used to create a new instance of this brush using the same pipeline, on threads that can't access the current instance, for example in secondary app windows.
/// </remarks>
/// <returns>A <see cref="XamlCompositionBrush"/> instance using the current effects pipeline</returns>
[Pure]
public XamlCompositionBrush Clone()
{
if (this.Dispatcher.HasThreadAccess)
{
throw new InvalidOperationException("The current thread already has access to the brush dispatcher, so a clone operation is not necessary. " +
"You can just assign this brush to an arbitrary number of controls and it will still work correctly. " +
"This method is only meant to be used to create a new instance of this brush using the same pipeline, " +
"on threads that can't access the current instance, for example in secondary app windows.");
}
return new XamlCompositionBrush(this.Pipeline);
}
}

Просмотреть файл

@ -153,13 +153,13 @@ namespace Microsoft.Toolkit.Uwp.UI
}
else if (element is ContentControl contentControl)
{
if (contentControl.Content is T result && predicate.Match(result))
{
return result;
}
if (contentControl.Content is FrameworkElement content)
{
if (content is T result && predicate.Match(result))
{
return result;
}
element = content;
goto Start;
@ -167,29 +167,46 @@ namespace Microsoft.Toolkit.Uwp.UI
}
else if (element is Border border)
{
if (border.Child is T result && predicate.Match(result))
{
return result;
}
if (border.Child is FrameworkElement child)
{
if (child is T result && predicate.Match(result))
{
return result;
}
element = child;
goto Start;
}
}
else if (element is ContentPresenter contentPresenter)
{
// Sometimes ContentPresenter is used in control templates instead of ContentControl,
// therefore we should still check if its Content is a matching FrameworkElement instance.
// This also makes this work for SwitchPresenter.
if (contentPresenter.Content is FrameworkElement content)
{
if (content is T result && predicate.Match(result))
{
return result;
}
element = content;
goto Start;
}
}
else if (element is UserControl userControl)
{
// We put UserControl right before the slower reflection fallback path as
// this type is less likely to be used compared to the other ones above.
if (userControl.Content is T result && predicate.Match(result))
{
return result;
}
if (userControl.Content is FrameworkElement content)
{
if (content is T result && predicate.Match(result))
{
return result;
}
element = content;
goto Start;
@ -370,6 +387,17 @@ namespace Microsoft.Toolkit.Uwp.UI
goto Start;
}
}
else if (element is ContentPresenter contentPresenter)
{
if (contentPresenter.Content is FrameworkElement content)
{
yield return content;
element = content;
goto Start;
}
}
else if (element is UserControl userControl)
{
if (userControl.Content is FrameworkElement content)

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше