I have two animations defined in my silverlight app :
<Storyboard x:Name="ShowControls">
<DoubleAnimation Duration="0:0:0.2" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="SlideOutMenu" />
</Storyboard>
<Storyboard x:Name="Hide-Controls">
<DoubleAnimation Duration="0:0:0.2" To="180" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="SlideOutMenu" />
</Storyboard>
When these Storyboards are defined in an external styles xaml file they dont work. I havent been able to figure out why I cant programmatically access these resources.
This code works for other resource types like brushes and templates so... I suspect that this resource dictionary issue is specific to Resources of the type Storyboard.
This is the code that throws the error: (SlideOutMenu is a Border Control).
public void AddEventHandlers()
{
SlideOutMenu.MouseEnter += new MouseEventHandler(SlideOutMenu_MouseEnter);
SlideOutMenu.MouseLeave += new MouseEventHandler(SlideOutMenu_MouseLeave);
}
public void SlideOutMenu_MouseEnter(object sender, MouseEventArgs e)
{
Storyboard showMenu = Application.Current.Resources["ShowControls"] as Storyboard;
showMenu.Begin();
}
Any Ideas ?