DataGrid单元格模板 [英] DataGrid Cell Template
本文介绍了DataGrid单元格模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的数据网格中,我有20列。我启用autogeneratecolumns = true。现在一个列包含国家/地区名称。现在每个国家/地区都要显示该国家/地区的名称和图像。如果不手动定义列,请执行此操作???
In my data grid i have 20 columns.I enable autogeneratecolumns=true.Now one colums contains country names.now for each country i want to display the name and a image of that country.how to do this without defining columns manually???
推荐答案
您可以创建一个用于保存国家/地区详细信息的类(名称,图像等):
You can create a class for holding the country''s details (name, image etc...):
class Country
{
// Add Some properties
}
添加属性在您的数据中保存国家/地区的详细信息,并添加 DataTemplate 国家
类:
add property for holding the country''s details in your data and, add a DataTemplate for the Country
class:
<DataTemplate DataType="{x:Type mynamespace:Country}">
<!-- ... -->
</DataTemplate>
这篇关于DataGrid单元格模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文