Skip to content

Commit 18e8447

Browse files
committed
Update 2019-01-25-Showing-Gridlines-In-Xamarin-Forms-Previewer.md
1 parent 1ac35c1 commit 18e8447

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

_drafts/2019-01-25-Showing-Gridlines-In-Xamarin-Forms-Previewer.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ published: false
33
---
44
## Showing Gridlines In Xamarin Forms Previewer
55

6-
I do a lot of work with Xamarin Forms. I'm in the XAML Previewer for much of my working day as I create new features and fix bugs in our company's app.
6+
This blog post describes how to show make a Xamarin.Forms `Grid` show its columns and rows graphically in the Visual Studio XAML Preview.
77

88
One of the things about the Previewer that has always frustrated me is that it doesn't show the outlines of any of the objects that I place in a form.
99

10-
One way to visualise the grid is to apply a `BackgroundColor` to each object being added. However, it's easy to see that this is ugly, prone to errors (I have accidentally shipped something with a `Fuchsia` (hot pink) background at least once) and extremely tedious.
10+
A simple way to visualise the grid is to create some `BoxView` objects, give them `BackgroundColor`, and add them to the `Grid`. However, it's easy to see that this is ugly, prone to errors (I have accidentally shipped something with a hot pink background at least once) and extremely tedious.
1111

12-
The search for a solution led initially to a custom renderer. Delving into the source of Xamarin Forms revealed that the `Grid` object is a subclass of `Layout<View>`, but it has no renderer of its own - all it does is manage a collection of child views and arrange them grid-fashion in its parent view.
12+
Xamarin.Forms objects are cross-platform virtualisations that draw on each platform by means of a Renderer. Delving into the source of Xamarin Forms revealed that the `Grid` object is a subclass of `Layout<View>`, but unusually it has no renderer of its own. This is because all it does is manage a collection of child views and arrange them grid-fashion in its parent view.
1313

14-
To create the custom renderer, subclass `Grid` in your platform-independent code to make a `PreviewGrid`:
14+
Most Xamarin.Forms objects are open for subclassing. The `Grid` object definitely is, so we can subclass it in our platform-independent code to make a `PreviewGrid`:
1515

1616
```
1717
using Xamarin.Forms;

0 commit comments

Comments
 (0)