要動畫厚度,使用這樣的故事板(從MSDN示例):
<BeginStoryboard>
<Storyboard>
<!-- BorderThickness animates from left=1, right=1, top=1, and bottom=1 to
left=28, right=28, top=14, and bottom=14 over one second. -->
<ThicknessAnimation
Storyboard.TargetProperty="BorderThickness"
Duration="0:0:1.5" FillBehavior="HoldEnd" From="1,1,1,1" To="28,14,28,14" />
</Storyboard>
</BeginStoryboard>
實際上,動態顯示取值爲 「W,X,Y,Z」 的任何財產您使用ThicknessAnimation
在我看來,你想要做的是將紅色的矩形移動到右邊。
在這種情況下,將整個事情放在Canvas
中,並在紅色矩形的位置上使用DoubleAnimation。
無論哪種方式,你得到的錯誤不是來自你提供的一小段代碼,如果你想要的話,請提供更多的代碼。
編輯:自ThicknessAnimation似乎是WP7不可用,試試這個來代替:
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="BorderThickness.Top"
Duration="0:0:1.5" To="15" />
<DoubleAnimation
Storyboard.TargetProperty="BorderThickness.Left"
Duration="0:0:1.5" To="25" />
</Storyboard>
</BeginStoryboard>
這是值得保留在WP7使用Silverlight的,其中有一些(HTTP [使用WPF細微的差別]記:// msdn.microsoft.com/en-us/library/cc903925(VS.95).aspx)。 –