0
我試圖讓一些圖像循環,有點像你在老虎機中看到的。 我目前的代碼更多的是一個選取框,所以圖像從頂部到底部,而他們正在移動一些空白後面的第一張圖片。WPF連續動畫
我該如何讓最後一幅圖像在循環中跟隨第一幅圖像?
XAML:
<Window x:Class="SlotV3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Slot Machine" Height="600" Width="800" Loaded="Window_Loaded">
<Grid>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="634,185,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
<Canvas Name="canvas1" Margin="82,49,458,12" ClipToBounds="True" Height="500">
<StackPanel Height="1043" Name="stackPanel1" Width="193" Canvas.Left="28" Canvas.Top="8">
images here...
</StackPanel>
</Canvas>
</Grid>
,並使用動畫代碼IM:
DoubleAnimation da = new DoubleAnimation();
da.From = -stackPanel1.ActualHeight;
da.To = canvas1.ActualHeight;
da.Duration = new Duration(TimeSpan.FromSeconds(0.25));
da.RepeatBehavior = RepeatBehavior.Forever;
stackPanel1.BeginAnimation(Canvas.TopProperty, da);