Invoking animation on VisibilityProperty from code behind throws an exception
Posted: 11 Feb 2022, 16:48
Hi!
I have created a storyboard with several animations, which I clone and change targets in code behind. All animations are DoubleAnimation, except for one which is ObjectAnimationUsingKeyFrames on Visibility. Whenever I run that one it throws an exception:
I've tested it again by modifying sample ApplicationTutorial and creating a storyboard as a resource and running it in code behind, I get the same problem.
[
I have created a storyboard with several animations, which I clone and change targets in code behind. All animations are DoubleAnimation, except for one which is ObjectAnimationUsingKeyFrames on Visibility. Whenever I run that one it throws an exception:
Code: Select all
System.InvalidOperationException
HResult=0x80131509
Message=Native type is not registered
Source=Noesis.GUI
StackTrace:
at Noesis.Extend.GetNativeTypeInfo(IntPtr nativeType)
at Noesis.AnimationTimeline.get_TargetPropertyType()
at Noesis.AnimationTimeline.IsValidTarget(DependencyProperty dp)
at Noesis.UIElement.BeginAnimation(DependencyProperty dp, AnimationTimeline animation, HandoffBehavior handoffBehavior)
at Noesis.UIElement.BeginAnimation(DependencyProperty dp, AnimationTimeline animation)
at RssReader.MainWindow.OnNextClicked(Object sender, RoutedEventArgs e) in F:\WORK\NoesisGUI-ManagedSDK-3.1.2\Src\Samples\ApplicationTutorial\Src\MainWindow.xaml.cs:line 113
at Noesis.RoutedEventArgs.InvokeHandler(Delegate handler, IntPtr sender, IntPtr args)
at Noesis.EventManager.InvokeHandler(IntPtr routedEventPtr, Delegate handler, IntPtr sender, IntPtr args)
at Noesis.EventHandlerStore.RaiseRoutedEvent(IntPtr cPtrType, IntPtr cPtr, IntPtr routedEvent, IntPtr sender, IntPtr e)
[
Code: Select all
<Window.Resources>
<Storyboard x:Key="TestStoryboard">
<ObjectAnimationUsingKeyFrames
Storyboard.TargetName="Prev"
Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="00:00:00.0" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>Code: Select all
void OnNextClicked(object sender, RoutedEventArgs e)
{
var board = (Storyboard)FindResource("TestStoryboard");
// board.Begin(); // this works but doesn't allow me to specify individual animations' targets
var anim = (AnimationTimeline)board.Children[0];
var bt = (Button)FindName("Prev");
// none of these 3 work in Noesis even if I set the target to the same value as original. Skipping them all and just running BeginAnimation also doesn't work.
//anim.SetValue(Storyboard.TargetNameProperty, "Prev");
//Storyboard.SetTarget(anim, bt);
//Storyboard.SetTargetName(anim, "Prev");
bt.BeginAnimation(Button.VisibilityProperty, anim);
}