Skip to content

Commit fe61714

Browse files
author
abadgirlnoa
committed
优化图表控件的动画效果
1 parent 12311a5 commit fe61714

File tree

1 file changed

+8
-4
lines changed
  • src/Local/Project1.UI/Controls/ChartControl

1 file changed

+8
-4
lines changed

src/Local/Project1.UI/Controls/ChartControl/Chart.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,7 @@ public Chart()
421421
{
422422
DefaultStyleKey = typeof(Chart);
423423
storyboard = new Storyboard();
424-
storyboard.Duration = TimeSpan.FromSeconds(1);
425424
scrollStoryboard = new Storyboard();
426-
//scrollStoryboard.Duration = TimeSpan.FromSeconds(1);
427425
scrollStoryboard.Completed += (e, c) =>
428426
{
429427
//容器滚动动画结束
@@ -541,10 +539,13 @@ public override void OnApplyTemplate()
541539
};
542540
}
543541
MouseLeave += Chart_MouseLeave;
544-
Render();
545-
//Loaded += Chart_Loaded;
542+
Loaded += Chart_Loaded;
546543
}
547544

545+
private void Chart_Loaded(object sender, RoutedEventArgs e)
546+
{
547+
Render();
548+
}
548549

549550
private void Render()
550551
{
@@ -709,6 +710,9 @@ private void InitAnimation()
709710
Storyboard.SetTarget(averageLabelValueAnimation, this);
710711
Storyboard.SetTargetProperty(averageLabelValueAnimation, new PropertyPath(AverageProperty));
711712

713+
averageAnimation.Duration= new Duration(TimeSpan.FromSeconds(.8));
714+
averageLabelAnimation.Duration = new Duration(TimeSpan.FromSeconds(.8));
715+
averageLabelValueAnimation.Duration = new Duration(TimeSpan.FromSeconds(.8));
712716

713717
storyboard.Children.Add(averageAnimation);
714718
storyboard.Children.Add(averageLabelAnimation);

0 commit comments

Comments
 (0)