0

I'd like to personalize my button's behavior on some states, like PointerOver or Disabled. I've found this answer, wich gave me a big help, but I still don't get how to personalize the button with my personal resources. i.e. I'd like to change the button's background when it's disabled, so I wrote something like:

<Image x:Key="myImage" src="Images/myImage.png" />

[...]

<VisualState x:Name="Disabled">
    <Storyboard>
        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Border">
            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource myImage}"/>
        </ObjectAnimationUsingKeyFrames>
    </Storyboard>
</VisualState>

But exception occurs. I can't tell you what's the exception, I think 'cause XAML is debugged by low-level c++ debugger and no particular exception is thrown.

What am I doing wrong?

EDIT: The exception is raised in the file App.g.i.cs at the foruth line of this block:

#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
        UnhandledException += (sender, e) =>
        {
            if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
        };
#endif

EDIT2: If I examine e in the debug session:

  • [System.Runtime.InteropServices.COMException] = {"Error HRESULT E_FAIL has been returned from a call to a COM component."}

  • Message = "Failed to assign to property 'Windows.UI.Xaml.Media.Animation.ObjectKeyFrame.Value'. [Line: 32 Position: 91]"

  • _stackTrace = null

4

0 回答 0