【发布时间】:2021-01-14 02:53:18
【问题描述】:
我正在尝试在我的故事板完成后执行一个命令。但这样做我得到一个 InvalidOperationException: 'System.Windows.Interactivity.EventTrigger' 类型的指定值必须将 IsFrozen 设置为 false 才能修改。'
这是我的代码:
<ItemsControl x:Name="ItemsControl"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Width="250">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border x:Name="MainBorder"
Background="Gray"
Margin="10"
Height="100">
<Border.RenderTransform>
<TranslateTransform X="0"/>
</Border.RenderTransform>
<Button BorderThickness="0"
BorderBrush="Transparent"
Background="Transparent"
Foreground="Black"
Width="20"
Height="20"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Content="x">
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Completed">
<i:InvokeCommandAction Command="{Binding DataContext.ClearToastCommand, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
CommandParameter="{Binding .}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<DoubleAnimation By="260"
Duration="0:0:1"
Storyboard.TargetName="MainBorder"
Storyboard.TargetProperty="RenderTransform.X">
<DoubleAnimation.EasingFunction>
<PowerEase EasingMode="EaseOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.Items>
<system:String>ItemsControl Item #1</system:String>
</ItemsControl.Items>
</ItemsControl>
感谢您的帮助!
【问题讨论】:
标签: xaml storyboard eventtrigger