I want to make a custom grid control, because the default doesn't support showing grid lines. I found a wpf solution for this, but the winrt lacks few features that the wpf supports. The code in the wpf soulution is something like this :
protected override void OnRender(DrawingContext dc)
{
if (ShowCustomGridLines)
{
foreach (var rowDefinition in RowDefinitions)
{
dc.DrawLine(new Pen(GridLineBrush, GridLineThickness), new Point(0, rowDefinition.Offset), new Point(ActualWidth, rowDefinition.Offset));
}
foreach (var columnDefinition in ColumnDefinitions)
{
dc.DrawLine(new Pen(GridLineBrush, GridLineThickness), new Point(columnDefinition.Offset, 0), new Point(columnDefinition.Offset, ActualHeight));
}
dc.DrawRectangle(Brushes.Transparent, new Pen(GridLineBrush, GridLineThickness), new Rect(0, 0, ActualWidth, ActualHeight));
}
base.OnRender(dc);
}
However I can't override the onrender method, and there is no drawingcontext in winrt. So how can I draw gridlines to my grid? Thanks for the help!
If you want to not have to put borders around every single element what I do is basically what you do but in xaml just essentially draw them kind of like for example;
This way you can have cells arranged however you like and you can cut down on having to nest everything in borders. Hope it helps. Cheers!
From Microsoft documentation :
Grid lines are not supported by metro for this reason (design tool only), so I assume you have to put borders on your child elements, according to Microsoft documentation.