Sumel007
Topic Author
Posts: 30
Joined: 19 Mar 2020, 10:50

Invoking animation on VisibilityProperty from code behind throws an exception

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:
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)
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.

[
<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>
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);

        }
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Invoking animation on VisibilityProperty from code behind throws an exception

11 Feb 2022, 20:51

Could you please report this in our bugtracker, it is clearly a bug.
Thanks for your collaboration.

In the meantime, you can create a Storyboard to launch the animation directly (instead of calling element.BeginAnimation):
Storyboar storyboard = CreateAnimation(...);
storyboard.Begin(element)
 
Sumel007
Topic Author
Posts: 30
Joined: 19 Mar 2020, 10:50

Re: Invoking animation on VisibilityProperty from code behind throws an exception

14 Feb 2022, 10:28

Alright, I've added the report. Thanks for your help!
https://www.noesisengine.com/bugs/view.php?id=2280
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Invoking animation on VisibilityProperty from code behind throws an exception

14 Feb 2022, 10:57

Thank you.

Who is online

Users browsing this forum: Ahrefs [Bot], maherne and 51 guests