111,129
社区成员
发帖
与我相关
我的任务
分享 <Button x:Name="button" Content="Button">
<Button.Style>
<Style>
<Style.Triggers>
<Trigger Property="Button.IsMouseOver" Value="True">
<Setter Property="Button.Background" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
void StartAnimiation()
{
DoubleAnimation daleft = new DoubleAnimation();
daleft.Duration = new Duration(new TimeSpan(0, 0, 0, 0, AnimationDuration));
daleft.RepeatBehavior = new RepeatBehavior(1);
daleft.AutoReverse = false;
Thickness tkleft = leftdoor.Margin;
ThicknessAnimation taleft = new ThicknessAnimation();
taleft.From = tkleft;
taleft.Duration = new Duration(new TimeSpan(0, 0, 0, 0, AnimationDuration));
DoubleAnimation daright = new DoubleAnimation();
daright.Duration = new Duration(new TimeSpan(0, 0, 0, 0, AnimationDuration));
daright.RepeatBehavior = new RepeatBehavior(1);
daright.AutoReverse = false;
Thickness tkright = rightdoor.Margin;
ThicknessAnimation taright = new ThicknessAnimation();
taright.From = tkright;
taright.Duration = new Duration(new TimeSpan(0, 0, 0, 0, AnimationDuration));
if (isOpened)
{
daleft.From = this.leftdoor.Width;
daleft.To = this.Width / 2 - OpenWidth;
tkleft.Right = this.Width - OpenWidth;
taleft.To = tkleft;
daright.From = this.rightdoor.Width;
daright.To = this.Width / 2 - OpenWidth;
tkright.Left = this.Width - OpenWidth;
taright.To = tkright;
}
else
{
daleft.From = this.leftdoor.Width;
daleft.To = this.Width / 2;
tkleft.Right = (this.Width / 2);
taleft.To = tkleft;
daright.From = this.rightdoor.Width;
daright.To = this.Width / 2;
tkright.Left = (this.Width / 2);
taright.To = tkright;
}
Storyboard sbleft = new Storyboard();
Storyboard.SetTargetProperty(taleft, new PropertyPath(Rectangle.MarginProperty));
sbleft.Children.Add(taleft);
Storyboard.SetTargetProperty(daleft, new PropertyPath(Rectangle.WidthProperty));
sbleft.Children.Add(daleft);
sbleft.Begin(leftdoor);
Storyboard sbright = new Storyboard();
Storyboard.SetTargetProperty(taright, new PropertyPath(Rectangle.MarginProperty));
sbright.Children.Add(taright);
Storyboard.SetTargetProperty(daright, new PropertyPath(Rectangle.WidthProperty));
sbright.Children.Add(daright);
sbright.Begin(rightdoor);
}


