0
我目前正在實現一個按鈕的自定義樣式,並希望用VisualStateManager定義不同的狀態(例如,按下)。VisualStateManager引發的異常
<Style x:Name="customStyle" TargetType="Button">
<Setter Property="ClickMode" Value="Release"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="RootElement" Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="Pressed">
<Storyboard>
<ColorAnimation Storyboard.TargetName="RootElement"
Storyboard.TargetProperty="Background"
To="Red"
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
...
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
正如你可以看到我想要到網格的背景屬性更改爲在按下狀態色紅,但下面的異常被拋出:
第一次機會異常在0x7708210B(KERNELBASE .DLL)在gymlog.exe中:0x40080201:WinRT發生錯誤(參數:0x800F1000,0x00000056,0x0178E4F4)。
如果我跳到特定的內存住址下面被顯示:
ColorAnimation不能用於動畫屬性Background由於不兼容的類型
如何解決這個問題?
不錯,現在它的作品,感謝您的答案。我只有另一個關於VisualStateManager的離題問題。是否可以更改圖片顏色(由於它是非alpha通道)? – neuronalbit 2015-03-19 16:01:57