silverlight教程(4)---使用风格元素,以更好地概括外观与感觉
来源:百度文库 编辑:神马文学网 时间:2024/04/28 09:16:35
Note: In addition to defining basic property settings (Color, Font, Size, Margins, etc), styles in WPF and Silverlight can also be used to define and re-use Control Templates - which enable super rich skinning and adaptation of control structure (and support customization scenarios not possible with CSS in HTML today). I discuss Control Templates in Part 7 of this series. 注:除界定基本属性的设置(颜色,字体,大小,利润率等) ,风格wpf和silverlight也可以被用来界定和再利用控制模板-使超级富豪的s kinning功能和适应的控制结构(并支持个性化的情况,不可能同的CSS在HTML今日) ,我讨论控制模板,在第7部的这一系列。
For our Digg sample application we'll define our Style declarations within the App.xaml file of our project. This will enable them to be reused across all pages and controls in the application:我们digg采样应用,我们将确定我们的作风报关单内app.xaml档案,我们的项目,这将使他们能够重复使用,所有的页面和控制中的应用:
Let's start by encapsulating styles for the
We can create two Style elements within our App.xaml file that encapsulate the
Note how we are giving each Style a unique "Key" value above. We can then update our
When we update the other controls within our Page.xaml file to use styles as well, we are left with a file that looks like below:当我们更新其他管制措施,我们page.xaml档案使用作风好,我们只剩下一个文件看起来像下面:
Encapsulate the style settings this way allows developers to better focus on the behavior semantics of the application, and also enables us to re-use styles across other controls/pages we build.概括了样式设置这种方式允许开发,以更好地着眼于行为语义学的应用,也使我们得以重新使用风格跨越其他管制/页,我们建立的。
Note: One issue to be aware of with Beta1 is that the error message when you mistype style names and property declarations is not very clear (it raises an exception but doesn't tell you what isn't set correctly). This will be improved in Beta2. 注:一个问题,他们必须明白,与素beta1是错误的讯息,当你错误的作风姓名及财产申报不很清楚(它提出了一个例外,但并没有告诉你什么是不正确设置) ,这将得到改善在间谍软件。 In the meantime if you see an error loading a style make sure to look carefully for typos. 在此期间,如果你看到一个错误装载的风格一定要仔细看看,为错别字。