0

我目前正在创建 customGrid 表,我目前面临的问题是每个单元格的边框,我得到了这个从背景反射的点状结构,我现在可以如何解决它。

在此处输入图像描述

我使用的代码是

 GridLength len2 = new GridLength(value);
                    Column.Width = len2;
                    tableGrid.ColumnDefinitions.Add(Column);
                    TextBlock textBlock = new TextBlock();

                    if (i == 0)
                    {
                        textBlock.Text = headers[j];
                        textBlock.FontSize = 35;
                        border = new Border();
                        border.Background = new SolidColorBrush(Colors.LightGray);
                        border.BorderBrush = new SolidColorBrush(Colors.White);

                        textBlock.HorizontalAlignment = HorizontalAlignment.Center;
                        textBlock.VerticalAlignment = VerticalAlignment.Center;
                        textBlock.Foreground = new SolidColorBrush(Colors.Black);
                    }
                    else
                    {
                        Debug.WriteLine("Data Value j is"+dataValues[j]);
                        textBlock.Text = "Content" + i + "/" + j;
                        //textBlock.Text = dataValues[j];
                        textBlock.FontSize = 25;
                        border = new Border();

                        textBlock.HorizontalAlignment = HorizontalAlignment.Center;
                        SolidColorBrush brush = GetColorFromHexa("0FFB0C4DE");/*0FFB0C4DE*/
                        border.Background = brush;

                        border.BorderBrush = new SolidColorBrush(Colors.White);

                    }

                    Grid.SetRow(border, i);
                    Grid.SetColumn(border, j);
                    tableGrid.Children.Add(border);
                    Grid.SetRow(textBlock, i);
                    Grid.SetColumn(textBlock, j);                            
                    tableGrid.Children.Add(textBlock);

任何需要更改的属性以避免每个单元格末尾的点边框?

4

1 回答 1

1

您应该将Grid.ShowGridLines设置为 false:

tableGrid.ShowGridLines = false;

于 2012-09-26T07:45:41.590 回答