Cannot create an animation in code-behind
Posted: 30 Jun 2014, 15:39
It's great that you can set up animations in your XAML file. However I have a situation where I want to set up an animation in the code-behind.
In my code I have a scrollviewer because not all content fits on the screen. If an item is made 'active' (from code behind), I want this scrollviewer to smoothly scroll towards this item. It is important that this is a smooth animation. I tried to do this using this code:
Unfortunately the 'BeginAnimation' method from WPF is not present in NoesisGUI.
Is there some workaround so I can set up an animation from code-behind?
In my code I have a scrollviewer because not all content fits on the screen. If an item is made 'active' (from code behind), I want this scrollviewer to smoothly scroll towards this item. It is important that this is a smooth animation. I tried to do this using this code:
Code: Select all
DoubleAnimation anim = new DoubleAnimation();
anim.SetFrom(new Noesis.NullableFloat(scrollViewer.GetHorizontalOffset()));
anim.SetTo(new Noesis.NullableFloat(_scrollViewerGoal));
anim.SetDuration(new Duration(new Noesis.TimeSpan(0.5)));
scrollViewer.BeginAnimation(ScrollViewer.HorizontalOffsetProperty, anim);
Is there some workaround so I can set up an animation from code-behind?