如何将形状设置为网格单元格的背景
我有一个 2 行 12 列的网格。 我需要合并一种样式,在每个单元格中绘制一个三角形 总共 24 个单元格,
例如三角形的几何形状:
M 0, 0 L 25, 250 L 50, 0 z
我如何为网格中的每个单元格的背景中的形状设计和使用样式?
行高约为 250 并且 列宽约为 50
或者,每个单元格包含一个堆栈面板
所以一个不同的解决方案是将其绘制为堆栈面板的背景,我怎样才能将形状绘制为堆栈面板的背景?
iv'e got a grid with 2 rows and 12 columns .
i need to incorporate a style which will draw a triangle for in each cell
total of 24 cells
the geometry for the triangle for the example :
M 0, 0 L 25, 250 L 50, 0 z
how could i design and use a style for with this shape in the background each cell in the Grid?
the rows height is approximately 250 and
column width is approximately 50
alternatively , each cell contains a stackpanel
so a different solution would be to draw it as the background of a stackpanel how could i draw the shape as the background of the stackpanel ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您所需要做的就是根据您的要求创建一个样式模板并将其应用到 DataGrid。因此,基本上您要做的就是将形状添加到 DefaultDataGridCellStyle 的模板中。我知道有几种方法可以做到这一点,但使用 Expression Blend 会容易得多。只需右键单击 Blend 中的数据网格,选择“编辑其他模板”->找到GridCell模板并“编辑副本”,几分钟即可完成。希望这有帮助!
使用三角形的路径数据和根据您的规格设置的高度/宽度的示例。
样式模板(基于默认的网格单元模板);
参考文献;
或者,如果您的字面意思只是默认常规网格的一个单元格;
All you need to do is create a style template for your requirements and apply it to the DataGrid. So basically all you do is add your shape to the template for the DefaultDataGridCellStyle. There's a couple ways of doing this I know of but it's much easier with Expression Blend. Just right-click your datagrid in Blend, choose "Edit Additional Templates" -> Find the GridCell template and "Edit A Copy", you can have it done minutes. Hope this helps!
Example using your path data for the triangle and the height/width set to your specs.
The style template (based off default gridcell template);
The ref;
Or if you literally meant just a cell to a default regular Grid;