-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6082 from wieslawsoltes/feature/SetterAnimatorAtt…
…achedPropertyHack Allow setting custom Animator in property to Setter (attached property alternative)
- Loading branch information
1 parent
6bac166
commit 5f4d2ef
Showing
5 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<UserControl | ||
xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:pages="clr-namespace:RenderDemo.Pages" | ||
x:Class="RenderDemo.Pages.CustomAnimatorPage" | ||
MaxWidth="600"> | ||
<Grid> | ||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"> | ||
<TextBlock.Styles> | ||
<Style Selector="TextBlock"> | ||
<Style.Animations> | ||
<Animation Duration="0:0:1" IterationCount="Infinite"> | ||
<KeyFrame Cue="0%"> | ||
<Setter Property="Text" Value="" Animation.Animator="{x:Type pages:CustomStringAnimator}"/> | ||
</KeyFrame> | ||
<KeyFrame Cue="100%"> | ||
<Setter Property="Text" Value="0123456789" Animation.Animator="{x:Type pages:CustomStringAnimator}"/> | ||
</KeyFrame> | ||
</Animation> | ||
</Style.Animations> | ||
</Style> | ||
</TextBlock.Styles> | ||
</TextBlock> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Reactive.Linq; | ||
using Avalonia; | ||
using Avalonia.Animation; | ||
using Avalonia.Controls; | ||
using Avalonia.Controls.Shapes; | ||
using Avalonia.Data; | ||
using Avalonia.Input; | ||
using Avalonia.Interactivity; | ||
using Avalonia.Markup.Xaml; | ||
using Avalonia.Media; | ||
using RenderDemo.ViewModels; | ||
|
||
namespace RenderDemo.Pages | ||
{ | ||
public class CustomAnimatorPage : UserControl | ||
{ | ||
public CustomAnimatorPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void InitializeComponent() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Avalonia.Animation.Animators; | ||
|
||
namespace RenderDemo.Pages | ||
{ | ||
public class CustomStringAnimator : Animator<string> | ||
{ | ||
public override string Interpolate(double progress, string oldValue, string newValue) | ||
{ | ||
if (newValue.Length == 0) return ""; | ||
var step = 1.0 / newValue.Length; | ||
var length = (int)(progress / step); | ||
var result = newValue.Substring(0, length + 1); | ||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters