我们有一个 UWP项目,目标是 Windows 10周年纪念版(10.0; Build 14393)。
我们在Code-Behind中触发了 Storyboard 。它以前工作;在我们定位Win 10周年纪念版之前。
但现在,每次调用 StoryBoard.Begin 时,它都会突然崩溃App。
以下是XAML:
<Grid.RenderTransform>
<CompositeTransform />
</Grid.RenderTransform>
<Grid.Resources>
<Storyboard x:Name="MoveX">
<DoubleAnimation Duration="0:0:0.15" Storyboard.TargetName="Grid_TemplateRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" To="-520">
<DoubleAnimation.EasingFunction>
<ElasticEase EasingMode="EaseOut" Oscillations="0" Springiness="1" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</Grid.Resources>
以下是代码隐藏:
var storyBoard = senderGrid.Resources["MoveX"] as Storyboard;
storyBoard.Completed += (s, o) => MoveX_Completed(item, deleteElementRef);
storyBoard.Begin();
其他人有经验并解决了这个问题吗?
编辑:这是MoveX_Completed方法:
private void MoveX_Completed(CompositeTransform item, Canvas deleteElementRef)
{
try
{
item.TranslateX = 0;
if (deleteElementRef.Visibility == Visibility.Visible)
{
deleteElementRef.Visibility = Visibility.Collapsed;
deleteElementRef.Background = new SolidColorBrush(Colors.Transparent);
}
var type = deleteElementRef.DataContext.GetType().Name;
if (type == "CheckItemViewModel")
{
var vm = deleteElementRef.DataContext as CheckItemViewModel;
if (vm != null)
vm.RemoveOrVoidFromCheckCommand.Execute(null);
}
else if (type == "CheckExtensionDataItemViewModel")
{
var vm = deleteElementRef.DataContext as CheckExtensionDataItemViewModel;
if (vm != null)
vm.RemoveOrVoidFromCheckCommand.Execute(null);
}
}
catch (Exception ex)
{
POSEventSource.Log.Warn("Error while swiping to delete check item, MoveX_Completed: " + ex.Message);
}
}
答案 0 :(得分:0)
似乎这是一个已知的错误。它与振荡设置为0有关。
解决方法是使用ExponentialEase。