Skip to content

Commit 90c964e

Browse files
committed
Update 2019-01-25-Showing-Gridlines-In-Xamarin-Forms-Previewer.md
1 parent c74d2d9 commit 90c964e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,18 @@ One of the things about the Previewer that has always frustrated me is that it d
99

1010
The standard tactic to get around this limitation 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.
1111

12-
I began to be convinced that "there must be a better way".
12+
I began to be convinced that "there must be a better way".
13+
14+
Initially a custom renderer looked like a good idea. 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.
15+
16+
The next step was to subclass the `Grid` to `PreviewGrid` and create the custom `PreviewGridRenderer`:
17+
18+
```
19+
PreviewGrid
20+
```
21+
22+
```
23+
PreviewGridRenderer
24+
```
25+
26+
I've left out most of the boilerplate code. If you want to see the whole example, it's available on my GitHub page.

0 commit comments

Comments
 (0)