"Can't Freeze BeginStoryboard.Storyboard" when using an attached property.
Posted: 16 Jun 2020, 21:38
I'm using the code here that allows me to use a command for a storyboard's Completed event.
However, when I try to use it with Noesis I get: "Can't Freeze BeginStoryboard.Storyboard" The storyboard plays but the command does not execute. If this is not possible with Noesis for some reason, is there a workaround? I can't use the Completed event in the code-behind because, from what I can tell, it doesn't give access to the particular data context and this storyboard is being used in an ItemsControl (I need the particular vm!).
Code: Select all
public static class StoryboardHelper
{
public static readonly DependencyProperty CompletedCommandProperty = DependencyProperty.RegisterAttached("CompletedCommand", typeof(ICommand), typeof(StoryboardHelper), new PropertyMetadata(null, OnCompletedCommandChanged));
public static readonly DependencyProperty CompletedCommandParameterProperty = DependencyProperty.RegisterAttached("CompletedCommandParameter", typeof(object), typeof(StoryboardHelper), new PropertyMetadata(null));
public static void SetCompletedCommand(DependencyObject o, ICommand value)
{
o.SetValue(CompletedCommandProperty, value);
}
public static ICommand GetCompletedCommand(DependencyObject o)
{
return (ICommand)o.GetValue(CompletedCommandProperty);
}
public static void SetCompletedCommandParameter(DependencyObject o, object value)
{
o.SetValue(CompletedCommandParameterProperty, value);
}
public static object GetCompletedCommandParameter(DependencyObject o)
{
return o.GetValue(CompletedCommandParameterProperty);
}
private static void OnCompletedCommandChanged(object sender, DependencyPropertyChangedEventArgs e)
{
var sb = sender as Storyboard;
if (sb != null)
{
sb.Completed += (a, b) =>
{
Code: Select all
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard local:StoryboardHelper.CompletedCommand="{Binding CompletedFinishedCommand}">
...
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>