[XAML]尝试以编程方式合并gridview中的单元格 [英] [XAML] Trying to merge cells in a gridview programmatically

查看:60
本文介绍了[XAML]尝试以编程方式合并gridview中的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好。我正在制作电视指南类型的应用程序,我正在使用GridView。我有数据进入gridview,但我遇到了一些问题。首先,我想让它看起来更像一个网格,我不确定是什么设置导致它
在每行上下都有大的边距,并且每个单元格周围没有边框。我还希望能够根据单元格的内容设置columnspan,所以如果我有一个空白单元格,那么之前的单元格和这个空白单元格应该变为1个单元格,其中
来自前一个单元格的内容,如合并excel中的单元格。我似乎无法弄清楚如何读取单元格内容然后更改columnspan。如果可以,请帮助我。

Good morning. I am making a TV Guide type app and I am using a GridView. I have the data going into the gridview but I am having a couple of issues. Firstly, I would like to make it look more like a grid and I am not sure what settings are causing it to have large margins above and below each row and to not have borders around each cell. I also want to be able to set columnspan based on the content of a cell, so if I have a blank cell then the cell before that and this blank cell should become 1 cell with the content from the previous cell, like merge cell in excel. I cannot seem to figure out how to read the cell contents and then change the columnspan. Please help me if you can.

非常感谢

< XAML for gridview>

<XAML for the gridview>

推荐答案

不幸的是,GridView和Excel并不完全相同。 

GridView and Excel are not quite the same, unfortunately. 

网上有很多关于如何在网格视图中测试和合并单元格的示例,搜索将各种产品从HTML返回到ASP.NET,所以我很感激你的混淆。

There are number of examples on the web on how to test and merge cells in a grid view, the search returns all kinds of products from HTML to ASP.NET, so I can appreciate your confusion.

我使用以下示例来帮助我开始一个新项目:
WPF DataGrid控件
 ,我刚刚使用VS 2015社区/企业版检查了代码,它在2016年3月7日在Windows 10 10586 1511上运行。

I use the following examples to get me started with a new project: WPF DataGrid Control , I checked the code just now using VS 2015 Community/Enterprise editions and it worked on 3/7/2016 running on Windows 10 10586 1511.

您可能需要设置属性或使用内置样式属性,因此请查看以下链接:

样式控件
,这将帮助您快速掌握样式,这将解决您的边界问题。

It is likely you need to set up attributes or use built-in style attributes so take a look at this link: Styling controls , this will help you get up to speed on styles, which should fix your border issues.

对于单元格的合并,请考虑这一点:

For the merging of cells consider this:

使用ItemDataBound中的列,否则,在ItemCreated中进行修改,您的代码可能看起来像执行空白单元格测试后,执行以下操作:

use the columns in ItemDataBound, otherwise, do the modifications in ItemCreated and your code might look like the following after performing your test for blank cell:

' set colspan 
 e.Item.Cells(2).ColumnSpan = 3 
 e.Item.Cells(3).Remove 
 e.Item.Cells(3).Remove





这篇关于[XAML]尝试以编程方式合并gridview中的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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