请问下面是什么问题导致的?比人新手,网多多指教 ↖(^ω^)↗发生了未处理的异常:
“System.Windows.Media.Animation.ColorAnimationUsingKeyFrames”动画对象不能用于动画属性“RuntimeEffect”,因为它是不兼容的类型“System.Windows.Media.Effects.Effect”。
   在 System.Windows.Media.Animation.Storyboard.VerifyAnimationIsValid(DependencyProperty targetProperty, AnimationClock animationClock)
   在 System.Windows.Media.Animation.Storyboard.ProcessComplexPath(HybridDictionary clockMappings, DependencyObject targetObject, PropertyPath path, AnimationClock animationClock, HandoffBehavior handoffBehavior, Int64 layer)
   在 System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive(Clock currentClock, DependencyObject containingObject, INameScope nameScope, DependencyObject parentObject, String parentObjectName, PropertyPath parentPropertyPath, HandoffBehavior handoffBehavior, HybridDictionary clockMappings, Int64 layer)
   在 System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive(Clock currentClock, DependencyObject containingObject, INameScope nameScope, DependencyObject parentObject, String parentObjectName, PropertyPath parentPropertyPath, HandoffBehavior handoffBehavior, HybridDictionary clockMappings, Int64 layer)
   在 System.Windows.Media.Animation.Storyboard.BeginCommon(DependencyObject containingObject, INameScope nameScope, HandoffBehavior handoffBehavior, Boolean isControllable, Int64 layer)
   在 System.Windows.VisualStateGroup.StartNewThenStopOld(FrameworkElement element, Storyboard[] newStoryboards)
   在 System.Windows.VisualStateManager.GoToStateInternal(FrameworkElement control, FrameworkElement stateGroupsRoot, VisualStateGroup group, VisualState state, Boolean useTransitions)
   在 System.Windows.VisualStateManager.GoToStateCommon(FrameworkElement control, FrameworkElement stateGroupsRoot, String stateName, Boolean useTransitions)
   在 System.Windows.VisualStateManager.GoToState(FrameworkElement control, String stateName, Boolean useTransitions)
   在 System.Windows.Controls.Primitives.ButtonBase.ChangeVisualState(Boolean useTransitions)
   在 System.Windows.Controls.Control.UpdateVisualState(Boolean useTransitions)
   在 System.Windows.Controls.Control.OnPostApplyTemplate()
   在 System.Windows.FrameworkElement.ApplyTemplate()
   在 Microsoft.Expression.Platform.WPF.WpfViewNodeManager.EnsureElementInDictionary(Object root, ViewNode knownAncestor)

解决方案 »

  1.   

    <Style x:Key="ButtonFocusVisual">
    <Setter Property="Control.Template">
    <Setter.Value>
    <ControlTemplate>
    <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    <LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
    <GradientStop Color="#F3F3F3" Offset="0"/>
    <GradientStop Color="#EBEBEB" Offset="0.5"/>
    <GradientStop Color="#DDDDDD" Offset="0.5"/>
    <GradientStop Color="#CDCDCD" Offset="1"/>
    </LinearGradientBrush>
    <SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/>
    <Style x:Key="ButtonStyle_Main" TargetType="{x:Type Button}">
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="{x:Type Button}">
    <Grid>
    <VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="CommonStates">
    <VisualStateGroup.Transitions>
    <VisualTransition From="Normal" GeneratedDuration="0:0:0.5" To="MouseOver"/>
    <VisualTransition From="MouseOver" GeneratedDuration="0:0:0.2" To="Normal"/>
    <VisualTransition From="MouseOver" GeneratedDuration="0:0:0.1" To="Pressed"/>
    <VisualTransition From="Pressed" GeneratedDuration="0:0:0.1" To="MouseOver"/>
    </VisualStateGroup.Transitions>
    <VisualState x:Name="Normal">
    <Storyboard>
    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)" Storyboard.TargetName="ellipse">
    <EasingColorKeyFrame KeyTime="0" Value="#FFFFFA00"/>
    </ColorAnimationUsingKeyFrames>
    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Direction)" Storyboard.TargetName="ellipse">
    <EasingDoubleKeyFrame KeyTime="0" Value="125"/>
    </DoubleAnimationUsingKeyFrames>
    </Storyboard>
    </VisualState>
    <VisualState x:Name="MouseOver">
    <Storyboard>
    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="ellipse">
    <EasingColorKeyFrame KeyTime="0" Value="#FFE4EA9F"/>
    </ColorAnimationUsingKeyFrames>
    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Color)" Storyboard.TargetName="ellipse">
    <EasingColorKeyFrame KeyTime="0" Value="#FFBFE20E"/>
    </ColorAnimationUsingKeyFrames>
    </Storyboard>
    </VisualState>
    <VisualState x:Name="Pressed">
    <Storyboard>
    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)" Storyboard.TargetName="ellipse">
    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
    </DoubleAnimationUsingKeyFrames>
    </Storyboard>
    </VisualState>
    <VisualState x:Name="Disabled"/>
    </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Ellipse x:Name="ellipse" Margin="8" Stroke="#FFECFF00">
    <Ellipse.Effect>
    <DropShadowEffect/>
    </Ellipse.Effect>
    <Ellipse.Fill>
    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.905,-0.215">
    <GradientStop Color="#FFFFEE00" Offset="0"/>
    <GradientStop Color="#FFA2E40E" Offset="1"/>
    </LinearGradientBrush>
    </Ellipse.Fill>
    </Ellipse>
    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
    </Grid>
    <ControlTemplate.Triggers>
    <Trigger Property="IsFocused" Value="True"/>
    <Trigger Property="IsDefaulted" Value="True"/>
    <Trigger Property="IsMouseOver" Value="True"/>
    <Trigger Property="IsPressed" Value="True"/>
    <Trigger Property="IsEnabled" Value="False"/>
    </ControlTemplate.Triggers>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>就是这样一个style.......
      

  2.   

    我试了一下,可以编译可以运行,在Designer里会有针对RuntimeEffect的Exception
    和你确认一下现象