Silverlight DataGrid资源 [英] Silverlight DataGrid Resource

查看:62
本文介绍了Silverlight DataGrid资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Silverlight项目,其中包含许多页面;其中许多带有DataGrids.

在整个项目中,所有DataGrid都绑定到一个资源,该资源使DataGrid的样式相同(即,所有页面上的所有DataGrid的页眉,正文,字体,颜色,间距和边框都相同). br/>
但是,我的问题是,我需要几个DataGrid才能拥有自己的独特外观.

I have a silverlight project which contains many pages; many of them with DataGrids on them.

Throughout the project all of the DataGrids are bound to a resource which makes the style of the DataGrids the same (IE the header, body, fonts, color, spacing, and borders are the same on all the DataGrids on all the pages).

My problem, however, is that I need a couple DataGrids to have their own unique look. How can I stop this resource from being applied to these outlying DataGrids?

推荐答案

一种简单的方法是为这些DataGrid创建一组模板并分配键那些模板.然后,您可以将各个部分的模板绑定到那些DataGrid.
A simple way to do this is to create a set of templates for those DataGrids and assign keys to those templates. You can then bind the templates for the various parts to those DataGrids.


将这些模板复制到各自的视图中,然后对其进行修改,以便在这些视图中对其进行自定义.
如果需要在其他区域重用它们,请将它们移到资源字典中.

请注意,对于AFAIK,如果xaml中有一个模板,而资源字典中又有一个模板(两者都具有相同的名称),则xaml中的模板将具有更高的优先级.
Copy those templates into the respective views and then modify them so that they are customized within those views.
If there is a need to reuse them across another area, move them to the resource dictionary.

Note that, AFAIK, if there is a template within the xaml and another within the resource dictionary (both having the same name), the one within the xaml gets higher precedence.


这篇关于Silverlight DataGrid资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆