Skip to content

Commit 4d08d73

Browse files
committed
feat: a gallery that shows what the control can do, and four smaller gaps
Running Codejock''s property grid sample beside ours made the difference obvious, and most of it was not the control. Their sample shows about thirty kinds of item; ours showed eight, which reads as "this library supports less" when in fact almost all of theirs are a DataTemplate over the row and always were. So the gallery now shows them: a tick box with its own caption, a group of radios, a slider with a spin box, a masked field, an address field, an upper-cased field, a hyperlink, and a button inside an editor - none of which needed anything added to the library. Four things did. A colour now shows its channels beside the swatch, because the swatch says roughly which colour it is and somebody matching two of them needs exactly. A description can carry a glyph, and can name brushes for its own text, its value and its row. And a row can take the whole width with no name beside it, for a property whose editor is the point. The per-row brushes are named rather than handed over as objects, so a description stays a plain object - and setting them taught me something worth recording next to the code: a brush read from Application.Resources is whichever theme was current at the time, not the theme of the element it is about to paint. Writing one back unconditionally painted dark-theme text on a light window. Now nothing is written unless a description asked, and the value underneath stays the {ThemeResource} from the template. The diagnostics moved out to PropertyGridProbe, a separate repository that is not published, the same way DockingProbe sits beside DockingPanels. It is scaffolding rather than a sample and nobody cloning this wants it. The screenshot mode stays: it produces the README image.
1 parent 946c4e9 commit 4d08d73

14 files changed

Lines changed: 575 additions & 548 deletions

File tree

CONTRIBUTING.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,26 @@ Control templates, splitter dragging, focus and keyboard behaviour, and the visu
5050
are validated by running the gallery and trying them. Please say in the pull request what you tried
5151
by hand.
5252

53-
Two things the gallery can answer without a person watching:
53+
The gallery can take its own picture, which is how the image in the README is produced and a quick
54+
way to see that a layout change did not collapse something:
5455

5556
```
5657
dotnet run --project samples/PropertyGridGallery -- --screenshot gallery.png light
57-
dotnet run --project samples/PropertyGridGallery -- --diagnose report.txt
5858
```
5959

60-
The first opens the gallery, lets it settle, saves a picture and exits — how the image in the README
61-
is produced, and a quick way to see that a layout change did not collapse something. The second puts
62-
four hundred rows through the repeater, scrolls them, and reports what actually happened: how many
63-
elements were realized, how often they were recycled, and whether the content presenter kept the
64-
editor it had already built. Those are the questions the design rests on and the ones no unit test
65-
can reach; if you change how rows are realized, run it and put the numbers in the pull request.
60+
For the questions a picture cannot answer — does the repeater really virtualize, does it recycle
61+
rather than rebuild, how tall is a row, and above all *does anything write to the model while nobody
62+
is typing* — there is a separate throwaway application, **PropertyGridProbe**. It is not in this
63+
repository on purpose: it is scaffolding, not a sample, and nobody cloning the library wants it. It
64+
references this one by source, so clone it next door and run:
65+
66+
```
67+
dotnet run --project ../PropertyGridProbe -- --diagnose report.txt
68+
```
69+
70+
If you change how rows are realized, run it and put the numbers in the pull request. And when you add
71+
a measurement there to catch a specific bug, take the fix out and check that the probe reports it —
72+
a harness that always says zero is not evidence of anything.
6673

6774
Two rules keep the tests possible, and both are easy to break by accident:
6875

assets/gallery-dark.png

8.71 KB
Loading

assets/gallery.png

8.76 KB
Loading

samples/PropertyGridGallery/App.xaml.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace PropertyGridGallery;
55
public partial class App : Application
66
{
77
private Window? window;
8-
private Diagnostics? diagnostics;
98
private ScreenshotRun? screenshot;
109

1110
public App()
@@ -19,15 +18,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
1918
// writes the answers to a file and exits. See Diagnostics.cs.
2019
string[] arguments = Environment.GetCommandLineArgs();
2120

22-
int flag = Array.IndexOf(arguments, "--diagnose");
23-
if (flag >= 0 && flag + 1 < arguments.Length)
24-
{
25-
diagnostics = new Diagnostics(arguments[flag + 1]);
26-
diagnostics.Run();
27-
return;
28-
}
29-
30-
flag = Array.IndexOf(arguments, "--screenshot");
21+
int flag = Array.IndexOf(arguments, "--screenshot");
3122
if (flag >= 0 && flag + 1 < arguments.Length)
3223
{
3324
ElementTheme theme = arguments.Contains("dark")

0 commit comments

Comments
 (0)