wpf-animation

WPF - Starting animation after another animation is finished in xaml

◇◆丶佛笑我妖孽 提交于 2020-06-13 00:48:55
问题 I am using WPF and I have 2 storyboard animations. I want the second animation to start after the first one is finished. How do I do that in the xaml code? 回答1: I don't know if it is possible in Xaml, if you can use some code behind you can do something like this: <Storyboard x:Name="MyStoryboard" Completed="MyStoryboardCompleted" FillBehavior="Stop"> and in your code behind private void MyStoryboardCompleted(object sender, EventArgs e) { var thing = this.FindResource("MyOtherStorboard"); var

Animate button background color in XAML

我怕爱的太早我们不能终老 提交于 2020-01-02 08:03:15
问题 I new to WPF and XAML, so I have ResourceDictionary (one button for now): <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="ButtonProduct" TargetType="Button"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="OverridesDefaultStyle" Value="true"/> <Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate

Animate button background color in XAML

天涯浪子 提交于 2020-01-02 08:02:37
问题 I new to WPF and XAML, so I have ResourceDictionary (one button for now): <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="ButtonProduct" TargetType="Button"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="OverridesDefaultStyle" Value="true"/> <Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate

Is it possible to start same animation for different controls at same start time

蹲街弑〆低调 提交于 2019-12-13 02:13:28
问题 I have a story board with double animation, <Storyboard x:Name="Storyboard1"> <DoubleAnimation From="0" To="200" Duration="0:0:2" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)"> </DoubleAnimation> </Storyboard> and I just adding TargetNameProperty dynamically, private void set_animation_for_images(string target_name) { Storyboard1.Stop(); Storyboard1.SetValue(Storyboard.TargetNameProperty, target_name); Storyboard1.Begin(); } Here is it possible to

How to specify a target for animation?

一世执手 提交于 2019-12-12 03:26:25
问题 Before you read this question, please see this Now I have the storyboard defined in the user control resources and it gets triggered it on an event that is defined in ViewModel: <UserControl.Resources> <Storyboard x:Key="Storyboard2"> <DoubleAnimation Storyboard.TargetName="Btn_Import" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:2"/> <DoubleAnimation Storyboard.TargetName="Studio" Storyboard.TargetProperty="Opacity" From="0" To="{Binding StudioOpacityValue}" Duration="0

WPF Launch animation from code-behind in MVVM

久未见 提交于 2019-12-11 08:23:19
问题 I'm looking for the way to code-behind launch an animation on a control contained in an ControlTemplate . In my app I have custom templated buttons (playing menu role) created from an ObservableCollection : MainMenuViewModel : /// <summary> /// Menu items list /// </summary> private ObservableCollection<MenuItem> _items; .... /// <summary> /// Menu items list property /// </summary> public ObservableCollection<MenuItem> Items { get { return _items; } set { _items = value; } } MainMenuView :

'ColorAnimation' animation object cannot be used to animate property 'Background' because it is of incompatible type 'System.Windows.Media.Brush'

*爱你&永不变心* 提交于 2019-12-11 07:37:01
问题 I'm tring to use a ColorAnimation programmatically to animate a cell, but I got this when I perform storyboard.Begin() 'System.Windows.Media.Animation.ColorAnimation' animation object cannot be used to animate property 'Background' because it is of incompatible type 'System.Windows.Media.Brush'. I've defined my ColorAnimation as var storyBoard = new Storyboard(); ColorAnimation colorAnimation = new ColorAnimation { From = Colors.Red, To = Colors.CornflowerBlue, Duration = TimeSpan.FromSeconds

Dragging selected Item along with the mouse in WPF

扶醉桌前 提交于 2019-12-10 18:04:02
问题 I am using the following code for performing Drag & Drop in my StackPanel Childran, XAML <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="601" Width="637"> <StackPanel Name="sp" AllowDrop="True" Background="SkyBlue" PreviewMouseLeftButtonDown="sp_PreviewMouseLeftButtonDown" PreviewMouseLeftButtonUp="sp_PreviewMouseLeftButtonUp" PreviewMouseMove="sp

WPF panel slide in from left animation

梦想的初衷 提交于 2019-12-07 08:10:31
问题 I'm trying to get a Panel to animate a sliding in behavior in WPF. I'm new to animations and am having some trouble. The panel with fills from the center out rather than from the left and it only animates the first time. I know I'm doing something wrong so any help would be appreciated. Below is the markup for my animation. <Style.Triggers> <Trigger Property="Visibility" Value="Visible"> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation From="0" To="200" Duration="0:0:0.5

WPF panel slide in from left animation

爷,独闯天下 提交于 2019-12-05 11:55:00
I'm trying to get a Panel to animate a sliding in behavior in WPF. I'm new to animations and am having some trouble. The panel with fills from the center out rather than from the left and it only animates the first time. I know I'm doing something wrong so any help would be appreciated. Below is the markup for my animation. <Style.Triggers> <Trigger Property="Visibility" Value="Visible"> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation From="0" To="200" Duration="0:0:0.5" AccelerationRatio="0.2" DecelerationRatio="0.1" Storyboard.TargetProperty="Width"/> </Storyboard> <