darthmaule2
Topic Author
Posts: 98
Joined: 23 Oct 2014, 19:54

Crash when trying to attach command to storyboard completed event [Managed SDK version 2.2.4]

22 Sep 2019, 11:50

First I tried it this way, as per another forum post I saw:
<UserControl x:Class="Controls.SoftButton.SoftButtonControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:Controls.SoftButton"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:noesis="clr-namespace:NoesisGUIExtensions">
    <UserControl.Resources>
        <Storyboard x:Key="MenuItemLoad" noesis:EventToCommand.Event="Completed" noesis:EventToCommand.Command="{Binding SbUnloadStoryboardCommand}">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" Storyboard.TargetName="MenuItemBorder">
                <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="90"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        ...
But during the xaml parsing, the debug claims it cannot find EventToCommand.

So then I tried what I thought was the newer approach:
        <Storyboard x:Key="MenuItemLoad">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Completed">
                    <i:InvokeCommandAction Command="{Binding SbLoadStoryboardCommand}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" Storyboard.TargetName="MenuItemBorder">
                <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="90"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
But this crashes at runtime here:
GUI.LoadComponent(this, "Controls.SoftButton.SoftButtonControl.xaml");
Any ideas?
 
darthmaule2
Topic Author
Posts: 98
Joined: 23 Oct 2014, 19:54

Re: Crash when trying to attach command to storyboard completed event [Managed SDK version 2.2.4]

22 Sep 2019, 12:07

Here's the stack trace:

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Noesis.View.Noesis_View_Find(System.Runtime.InteropServices.HandleRef)
at Noesis.View.Noesis_View_Find(System.Runtime.InteropServices.HandleRef)
at Noesis.View.Find(Noesis.BaseComponent)
at NoesisApp.AttachableObject.Attach(Noesis.DependencyObject)
at NoesisApp.TriggerCollection.OnAttached()
at NoesisApp.AttachableCollection`1[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Attach(Noesis.DependencyObject)
at NoesisApp.Interaction.OnTriggersChanged(Noesis.DependencyObject, Noesis.DependencyPropertyChangedEventArgs)
at Noesis.PropertyMetadata.OnPropertyChanged(IntPtr, IntPtr, IntPtr)
at Noesis.GUI.Noesis_LoadComponent(System.Runtime.InteropServices.HandleRef, System.String)
at Noesis.GUI.Noesis_LoadComponent(System.Runtime.InteropServices.HandleRef, System.String)
at Noesis.GUI.LoadComponent(System.Object, System.String)
at Controls.SoftButton.SoftButtonControl.InitializeComponent()
at Controls.SoftButton.SoftButtonControl..ctor(System.String, Controls.SoftButton.SoftButtonViewModel)
at UIShell.App.RunApplication(SimpleInjector.Container)
at UIShell.App.OnStartup(NoesisApp.StartupEventArgs)
at NoesisApp.Application.Start()
at NoesisApp.Application.Run()
at UIShell.App.Main(System.String[])
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Crash when trying to attach command to storyboard completed event [Managed SDK version 2.2.4]

24 Sep 2019, 12:05

The code you wrote should have worked, but there was a bug we just fixed when using i:EventTrigger in a Storyboard resource. It will be solved in the next release.

In the meantime you can move the trigger to a element in the tree, and use the StoryboardCompletedTriger:
<Grid x:Name="LayoutRoot">
    <i:Interaction.Triggers>
        <i:StoryboardCompletedTrigger Storyboard="{StaticResource Intro}">
            <i:InvokeCommandAction Command="{Binding StartCommand}"/>
        </i:StoryboardCompletedTrigger>
    </i:Interaction.Triggers>
    ...
</Grid>

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests