Search code examples
c#windows-phone-7xamlbuttonpressed

C# WP7 Button Pressed state throwing: "Invalid attribute value for property Background."


Error: "Invalid attribute value for property Background."

XAML:

<VisualState x:Name="Pressed">
    <Storyboard>
        ....
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonBackground" Storyboard.TargetProperty="Background">
            <DiscreteObjectKeyFrame KeyTime="0" Value="/Images/home_2_click.png" />
        </ObjectAnimationUsingKeyFrames>
        ....
    </Storyboard>
</VisualState>

Solution

  • you seems to apply background imag to a button during animation. Certainly you are applying it in a wrong way. you must do the following:

    <DiscreteObjectKeyFrame KeyTime="0:0:1">
        <DiscreteObjectKeyFrame.Value>
            <ImageBrush ImageSource="" />
        </DiscreteObjectKeyFrame.Value>
    </DiscreteObjectKeyFrame>
    

    This will certainly solvers your problem. And if it does, then please mark this as an accepted answer. thanx