Próbuję zrobić animację z kodu przy użyciu klasy Storyboard. Nie ma klasy ThicknessAnimation. Próbowałem też stworzyć storyboard za pomocą Blend, to nie działa tam. po prostu przeskakuje bezpośrednio do nowej wartości, bez płynnej animacji.Czy istnieje sposób na animowanie właściwości Margin w aplikacjach w stylu Metro?
AKTUALIZACJA: Próbowałem użyć transformacji TłumaczX. Ale kiedy używam go na obrazku, obrazy są przycinane. Co próbuję zrobić, to animować duży obraz bardzo wolno w małej siatce, więc ma taki efekt (podobny do tego w Galerii Zune i Windows Phone). Gdy obraz otwiera zacznę animację, jest to mój kod:
private void Image_ImageOpened_1(object sender, RoutedEventArgs e)
{
var img = sender as Image;
Storyboard sb = new Storyboard();
var doubleAnimationx = new DoubleAnimation() { To = -100, SpeedRatio = 0.1, From = 0 };
Storyboard.SetTarget(doubleAnimationx, img);
Storyboard.SetTargetProperty(doubleAnimationx, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
sb.Children.Add(doubleAnimationx);
sb.Begin();
}
Xaml:
<Grid IsSwipeEnabled="True" ItemsSource="{Binding Source={StaticResource cvs1}}" ItemClick="ItemsGridView_ItemClick_1"
x:Name="ItemsGridView" Margin="50,20,116,46" SelectionMode="None" IsItemClickEnabled="True"
AutomationProperties.AutomationId="ItemsGridView"
AutomationProperties.Name="Grouped Items">
<Grid.ItemTemplate>
<DataTemplate>
<Grid Height="250" VariableSizedWrapGrid.ColumnSpan="{Binding ColumnSpan}" Margin="2">
<Image ImageOpened="Image_ImageOpened_1" Stretch="UniformToFill" Source="{Binding ImageHQ}" >
<Image.RenderTransform>
<CompositeTransform />
</Image.RenderTransform>
</Image>
<StackPanel VerticalAlignment="Bottom" Background="#AA000000">
<TextBlock Margin="5,5,5,0" FontSize="26" Text="{Binding Name,Mode=OneWay}" FontFamily="Arial Black" />
<TextBlock Margin="5,0,5,5" FontSize="24" Text="{Binding Section,Mode=OneWay}" Foreground="{Binding SectionColor,Mode=OneWay}" />
</StackPanel>
</Grid>
</DataTemplate>
</Grid.ItemTemplate>
</Grid>
Proszę ponownie sprawdzić moje pytanie, dodałem kilka szczegółów. dzięki :) – Ateik
@ user836252 dlaczego nie umieścić tego obrazu wewnątrz panelu stackpanel i przenieść panel. –
mimo to obraz zostanie przycięty. :( – Ateik