0
有被动画当在视图模型一个IsBusy布尔属性为True一个按钮:错误触发动画
<Button x:Name="button" Grid.Row="4"
Command="{Binding QuitCommand}"
Content="{x:Static r:Resources.Close}"
RenderTransformOrigin="0.5,0.5">
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding IsBusy}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource TestStoryboard}"/>
</DataTrigger.EnterActions>
</DataTrigger> **<-- here is line 167 position 27**
</Style.Triggers>
</Style>
</Button.Style>
<Button.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Button.RenderTransform>
</Button>
故事板:
<Window.Resources>
<Storyboard x:Key="TestStoryboard">
<DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="25"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="180"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
如果我初始化IsBusy属性为false,然后再启动动画,然后一切正常。
如果我初始化IsBusy属性为true,然后我得到了以下错误:
'[未知]' 属性不指向的DependencyObject路径 “(0)(1)[2 ]。(2)”。 '设置属性 'System.Windows.FrameworkElement.Style'抛出一个异常。'行 数字'167'和行位置'27'。
视图模型:
public const string IsBusyPropertyName = "IsBusy";
private bool _IsBusy = true;
public bool IsBusy
{
get
{
return _IsBusy;
}
set
{
if (_IsBusy == value)
{
return;
}
RaisePropertyChanging(IsBusyPropertyName);
_IsBusy = value;
RaisePropertyChanged(IsBusyPropertyName);
}
}
时机的问题?
怎么样'TestStoryboard',问题可能出在那里。 – 2014-08-28 14:51:56
@KingKing - 故事板确实有效,但如果我从一开始就将IsBusy设置为true,那么就不行。我发布它,所以你可以看到。 – 2014-08-28 14:54:36