-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ScrollViewer expression animations extensions #3220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
michael-hawker
merged 32 commits into
CommunityToolkit:master
from
Sergio0694:feature/scroll-viewer-expression-animations
May 29, 2020
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
afa5047
Merge pull request #10 from windows-toolkit/master
Sergio0694 e8cd4f7
Merge pull request #18 from windows-toolkit/master
Sergio0694 cbc80ef
Merge pull request #19 from windows-toolkit/master
Sergio0694 8c10171
Removed unnecessary using directive
Sergio0694 447434f
Added ScrollViewer expression animation extensions
Sergio0694 731eedb
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 bce0bb9
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 048f2fe
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 271bdfc
Added VisualProperty option
Sergio0694 a633fb4
Added example to ScrollViewerExtensions sample page
Sergio0694 f3fd843
Minor code refactoring
Sergio0694 b3d1281
Added C# sample code
Sergio0694 e35589f
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 28d31a6
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 c983cee
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 d4d6294
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 7050900
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 4d22f36
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 e7650f9
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 7c1cc4f
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 68ca8a4
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 68909c8
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 e40f3ad
Merge branch 'master' into feature/scroll-viewer-expression-animations
michael-hawker 31a1b8d
Fixed XML docs for the ScrollViewerExtensions class
Sergio0694 e1a6caa
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 50b455b
Added more docs to the sample page
Sergio0694 1a2c610
Tweaked sample page a bit more
Sergio0694 74c5d32
Removed bounding boxes in sample page
Sergio0694 89bec43
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 67f631e
Merge branch 'master' into feature/scroll-viewer-expression-animations
Sergio0694 5c366a4
Fixed more XML docs
Sergio0694 9423f04
Merge branch 'master' into feature/scroll-viewer-expression-animations
michael-hawker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 8 additions & 69 deletions
77
....Toolkit.Uwp.SampleApp/SamplePages/ScrollViewerExtensions/ScrollViewerExtensionsCode.bind
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,10 @@ | ||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:common="using:Microsoft.Toolkit.Uwp.SampleApp.Common" | ||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:extensions="using:Microsoft.Toolkit.Uwp.UI.Extensions" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
// C# - Scale can be applied to any UIElement. In this case it is an image called ToolkitLogo. | ||
using Microsoft.Toolkit.Uwp.UI.Extensions; | ||
|
||
<Page.Resources> | ||
<common:DoubleTopThicknessConverter x:Key="DoubleTopThicknessConverter" /> | ||
</Page.Resources> | ||
// Binds the Y scroll axis of the ScrollViewer to the Y translation axis of the target | ||
listScrollViewer.StartExpressionAnimation(shapesPanel, Axis.Y); | ||
|
||
<Grid> | ||
<ListView Name="listView" | ||
extensions:ScrollViewerExtensions.VerticalScrollBarMargin="{Binding MinHeight, ElementName=MyHeaderGrid, Converter={StaticResource DoubleTopThicknessConverter}}" | ||
extensions:ScrollViewerExtensions.EnableMiddleClickScrolling="@[EnableMiddleClickScrolling:Bool:True]"> | ||
<ListView.Header> | ||
<controls:ScrollHeader Mode="Sticky"> | ||
<Grid x:Name="MyHeaderGrid" | ||
MinHeight="@[Header MinHeight:DoubleSlider:250:150-500]" | ||
Background="{ThemeResource Brush-Sample-TransparentHeader}"> | ||
<StackPanel HorizontalAlignment="Center" | ||
VerticalAlignment="Center"> | ||
<TextBlock Margin="12" | ||
FontSize="48" | ||
FontWeight="Bold" | ||
Foreground="{ThemeResource Brush-Main}" | ||
Text="Scroll Header" | ||
TextAlignment="Center" | ||
TextWrapping="WrapWholeWords" /> | ||
<TextBlock Margin="12,0,12,12" | ||
VerticalAlignment="Center" | ||
Foreground="{ThemeResource Brush-Main}" | ||
Text="The attached property allows you to assign a Thickness to both vertical and horizontal ScrollBar inside any container. In this example, VerticalScrollBarMargin is bound to StickyHeader's MinHeight. Moving MinHeight's Slider will move the vertical ScrollBar accordingly." | ||
TextAlignment="Center" | ||
TextWrapping="WrapWholeWords" /> | ||
</StackPanel> | ||
</Grid> | ||
</controls:ScrollHeader> | ||
</ListView.Header> | ||
<ListView.ItemTemplate> | ||
<DataTemplate> | ||
<Grid MinHeight="100" | ||
Background="{ThemeResource Brush-Grey-03}"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<Image x:Name="ToolkitLogo" | ||
Grid.Column="0" | ||
Width="100" | ||
Height="100" | ||
Margin="0,0,24,0" | ||
Source="ms-appx:///Assets/ToolkitLogo.png" /> | ||
<TextBlock Grid.Column="1" | ||
VerticalAlignment="Center" | ||
Text="{Binding Title}" | ||
TextTrimming="CharacterEllipsis" /> | ||
</Grid> | ||
</DataTemplate> | ||
</ListView.ItemTemplate> | ||
<ListView.ItemContainerStyle> | ||
<Style TargetType="ListViewItem"> | ||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> | ||
<Setter Property="Padding" Value="12,12,24,12" /> | ||
</Style> | ||
</ListView.ItemContainerStyle> | ||
</ListView> | ||
</Grid> | ||
</Page> | ||
// It is also possible to synchronize different axes, as well as targeting | ||
// different Visual properties. By default, the expression works with the | ||
// Visual.Translate property, but Visual.Offset can be used as well. | ||
listScrollViewer.StartExpressionAnimation(shapesPanel, Axis.X, Axis.Y, VisualProperty.Offset); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
....Toolkit.Uwp.SampleApp/SamplePages/ScrollViewerExtensions/ScrollViewerExtensionsXaml.bind
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:common="using:Microsoft.Toolkit.Uwp.SampleApp.Common" | ||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:extensions="using:Microsoft.Toolkit.Uwp.UI.Extensions" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Page.Resources> | ||
<common:DoubleTopThicknessConverter x:Key="DoubleTopThicknessConverter" /> | ||
</Page.Resources> | ||
|
||
<Grid> | ||
<ListView Name="listView" | ||
extensions:ScrollViewerExtensions.VerticalScrollBarMargin="{Binding MinHeight, ElementName=MyHeaderGrid, Converter={StaticResource DoubleTopThicknessConverter}}" | ||
extensions:ScrollViewerExtensions.EnableMiddleClickScrolling="@[EnableMiddleClickScrolling:Bool:True]"> | ||
<ListView.Header> | ||
<controls:ScrollHeader Mode="Sticky"> | ||
<Grid x:Name="MyHeaderGrid" | ||
MinHeight="@[Header MinHeight:DoubleSlider:250:150-500]" | ||
Background="{ThemeResource Brush-Sample-TransparentHeader}"> | ||
<StackPanel HorizontalAlignment="Center" | ||
VerticalAlignment="Center"> | ||
<TextBlock Margin="12" | ||
FontSize="48" | ||
FontWeight="Bold" | ||
Foreground="{ThemeResource Brush-Main}" | ||
Text="Scroll Header" | ||
TextAlignment="Center" | ||
TextWrapping="WrapWholeWords" /> | ||
<TextBlock Margin="12,0,12,12" | ||
VerticalAlignment="Center" | ||
Foreground="{ThemeResource Brush-Main}" | ||
Text="The attached property allows you to assign a Thickness to both vertical and horizontal ScrollBar inside any container. In this example, VerticalScrollBarMargin is bound to StickyHeader's MinHeight. Moving MinHeight's Slider will move the vertical ScrollBar accordingly." | ||
TextAlignment="Center" | ||
TextWrapping="WrapWholeWords" /> | ||
</StackPanel> | ||
</Grid> | ||
</controls:ScrollHeader> | ||
</ListView.Header> | ||
<ListView.ItemTemplate> | ||
<DataTemplate> | ||
<Grid MinHeight="100" | ||
Background="{ThemeResource Brush-Grey-03}"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<Image x:Name="ToolkitLogo" | ||
Grid.Column="0" | ||
Width="100" | ||
Height="100" | ||
Margin="0,0,24,0" | ||
Source="ms-appx:///Assets/ToolkitLogo.png" /> | ||
<TextBlock Grid.Column="1" | ||
VerticalAlignment="Center" | ||
Text="{Binding Title}" | ||
TextTrimming="CharacterEllipsis" /> | ||
</Grid> | ||
</DataTemplate> | ||
</ListView.ItemTemplate> | ||
<ListView.ItemContainerStyle> | ||
<Style TargetType="ListViewItem"> | ||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> | ||
<Setter Property="Padding" Value="12,12,24,12" /> | ||
</Style> | ||
</ListView.ItemContainerStyle> | ||
</ListView> | ||
|
||
<!--This is the panel that will be animated in sync with the main ScrollViewer control inside | ||
the ListView in the page, using the ScrollViewerExtensions leveraging composition ExpressionAnimations. | ||
We use x:Name here to be able to reference the panel from code behind and start the animation. | ||
To inspect the C# code beind used, switch to the "Code" tab in this sample page.--> | ||
<StackPanel x:Name="shapesPanel" | ||
HorizontalAlignment="Center" | ||
Margin="{Binding MinHeight, ElementName=MyHeaderGrid, Converter={StaticResource DoubleTopThicknessConverter}}" | ||
Padding="88" | ||
Spacing="32"> | ||
<Polygon Height="100" | ||
Width="100" | ||
Points="0,0 0,72 44,36" | ||
Stroke="DarkGreen" | ||
Fill="Green" | ||
VerticalAlignment="Center" | ||
HorizontalAlignment="Center"/> | ||
<StackPanel Orientation="Horizontal" | ||
VerticalAlignment="Center" | ||
HorizontalAlignment="Center" | ||
Spacing="4" | ||
Height="84" | ||
Width="100"> | ||
<Polygon Points="0,0 0,56 32,28" | ||
Stroke="Blue" | ||
Fill="DodgerBlue"/> | ||
<Polygon Points="0,0 0,56 32,28" | ||
Stroke="Blue" | ||
Fill="DodgerBlue"/> | ||
</StackPanel> | ||
<TextBlock | ||
Height="100" | ||
FontSize="24" | ||
TextAlignment="Center"> | ||
<Run Text="Look at me, I'm floating between"/> | ||
<LineBreak/> | ||
<Run Text="two different ListView items!"/> | ||
</TextBlock> | ||
<Polygon Height="100" | ||
Width="100" | ||
Points="0,0 0,60 60,60 60,0" | ||
Stroke="DarkRed" | ||
Fill="Crimson" | ||
VerticalAlignment="Center" | ||
HorizontalAlignment="Center"/> | ||
</StackPanel> | ||
</Grid> | ||
</Page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Microsoft.Toolkit.Uwp.UI/Extensions/ScrollViewer/Enums/Axis.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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.UI.Extensions | ||
{ | ||
/// <summary> | ||
/// Indicates an axis in the 2D space | ||
/// </summary> | ||
public enum Axis | ||
{ | ||
/// <summary> | ||
/// The X axis (horizontal) | ||
/// </summary> | ||
X, | ||
|
||
/// <summary> | ||
/// The Y axis (vertical) | ||
/// </summary> | ||
Y | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Microsoft.Toolkit.Uwp.UI/Extensions/ScrollViewer/Enums/VisualProperty.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// 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.Composition; | ||
|
||
namespace Microsoft.Toolkit.Uwp.UI.Extensions | ||
{ | ||
/// <summary> | ||
/// Indicates a property of a <see cref="Visual"/> object. | ||
/// </summary> | ||
public enum VisualProperty | ||
{ | ||
/// <summary> | ||
/// The offset property of a <see cref="Visual"/> object. | ||
/// </summary> | ||
Offset, | ||
|
||
/// <summary> | ||
/// The translation property of a <see cref="Visual"/> object. | ||
/// </summary> | ||
Translation | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.