Silverlight中遇到的一些问题

1.UserControl.Resources是什么?起什么作用?

     1.自百度知道:Resource里面什么都可以放,但通常用于放程序会用到的资源,比如

        各种模板(ControlTemplate、DataTemplate...)

        各种样式(Style...)

        各种转值对象(继承于IValueConverter)等等

 Resources是FrameworkElement里的属性,几乎所有的控件都可以设置自己的Resources属性,比如可以为么一个TextBox单独添加专属样式,但这样会造成资源浪费,所以通常把通用的资源放到最上一层元素里,这样就可以被所有的子元素使用。如果一个资源整个项目都会用到,则可以把资源放到App.xaml里。

2.StaticResource标记扩展

   通过查找对已定义资源的引用,为任何XAML属性特性提供值。对该资源的查找行为类似于加载时查找,它会查找以前从当前XAML页的标记中加载的资源以及其他应用程序资源,并且将该资源生产为运行时对象中的属性值。

   原文:Provides a value for any XAML property attribute by looking up a reference to an already defined resource.Lookup behavior for that resource is analogous to load-time lookup, which will look for resources that were previously loaded from the markup of the current XAML page as well as other application sources, and will generate that resource value as the property value in the run-time objects

posted @ 2013-02-05 13:58  息晴海  阅读(149)  评论(0编辑  收藏  举报