问:
我想把故事板资源放在app.xaml文件里,可怎么在XXX.xaml文件里的控件里引用呢?
如在app.xaml文件里定这如下
<Application xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
x:Class=”SilverlightApplication3.App”
>
<Application.Resources>
<Storyboard x:Key=”myStoryboard”></Storyboard>
<TransformGroup x:Key=”myTransformGroup”></TransformGroup>
</Application.Resources>
</Application>
想在page.xaml文件里引用,能引用myStoryboard吗?怎么引用?
<UserControl x:Class=”SilverlightApplication3.Page”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
Width=”400″ Height=”300″>
<Canvas RenderTransform=”{StaticResource myTransformGroup}”>
<!–content–>
</Canvas>
</UserControl>
谢谢!!
答:
你的storyboard会有一个作用的对象,这个对象你准备在哪定义呢,所以这样定义资源式的storyboard 似乎并不太常见,但还是可以的。
可以参见:
大概意思就是写一个帮助类,这个类从app.xaml里载入这个storyborad, 然后动态改变其target属性等等,这样就可以实现你的需求了。
No tags
