Сделал простейшую форму на Silverlight 2.0. Шаблон для кнопки, сверху кнопки — прямоугольник. При наведении курсора на кнопку запускается DoubleAnimation для Rectangle.Width. Все замечательно работает. При попытке сделать то же самое для Button.Width — не работает (ничего не происходит). Причем, анимация для нешаблонизированной кнопки тоже замечательно работает. Может, я в шаблонах чего-то не понял?
<UserControl x:Class="AnimationOverview.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<StackPanel>
<StackPanel.Resources>
<Style TargetType="Button" x:Key="newTemplate">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<StackPanel x:Name='RootElement'>
<StackPanel.Resources>
<Storyboard x:Name="MouseOver State" >
<DoubleAnimation Storyboard.TargetName="rect"
Storyboard.TargetProperty="Width"
To="300" Duration="0:0:1"
AutoReverse="True" RepeatBehavior="Forever" />
</Storyboard>
</StackPanel.Resources>
<Rectangle x:Name="rect"
RadiusY="2" RadiusX="2" Width="200" Height="20" Fill="Red" />
<Button x:Name='btn'
Margin="4"
Content="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}"
FontSize="{TemplateBinding FontSize}"
Width="200" Height="20" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</StackPanel.Resources>
<Button x:Name="myButton" Style="{StaticResource newTemplate}" Content="resized button" />
</StackPanel>
</UserControl>