Skip to content

GameStudio: edit System.Guid properties in the property grid - #3280

Open
Nicogo1705 wants to merge 5 commits into
stride3d:masterfrom
Nicogo1705:editor-guid-property-support
Open

GameStudio: edit System.Guid properties in the property grid#3280
Nicogo1705 wants to merge 5 commits into
stride3d:masterfrom
Nicogo1705:editor-guid-property-support

Conversation

@Nicogo1705

Copy link
Copy Markdown
Contributor

PR Details

Guid members on components/assets previously fell through to the read-only
ObjectPropertyTemplateProvider fallback and rendered as a non-editable "Guid" row in the
property grid — there was no way to set them from Game Studio at all.

This PR adds a proper Guid editor, plus a few usability layers on top:

Editing — a GuidPropertyTemplateProvider (TypeMatchTemplateProvider, so it also covers
Nullable<Guid>) mirroring the string editor: a TextBox bound through a new GuidToString
value converter. No registration code needed: providers declared in
DefaultPropertyTemplateProviders.xaml are auto-registered, and the default OverrideRule.Some
takes precedence over the read-only fallback.

Commit-time validation — invalid text is passed through by ConvertBack, so the
strongly-typed node setter throws, TextBoxBase raises TextToSourceValueConversionFailed, and
the attached TextBoxPropertyValueValidationBehavior (same pattern as the UFile editor) plays
the red error adorner while the text reverts to the source value. The stored value can never be
corrupted.

Ghost template — while the editor has focus, the typed prefix is completed inline with the
remaining 0000…-0000 pattern in faint text (via a new GuidTemplateRemainder converter), so
the missing length and dash positions are visible at a glance.

Input mask (GuidInputMaskBehavior) —

  • hex input is regrouped live as 8-4-4-4-12, dashes inserted automatically (the caret hops past
    a freshly inserted dash);
  • deletions are not fought: backspacing a dash does not re-append it;
  • input is capped at the full 36-char template (MaxLength), replacing a selection still works;
  • pasted {guid} / (guid) forms are unwrapped;
  • non-hex content turns the text red immediately (purely visual, nothing is blocked or
    rewritten — commit-time validation does the hard reject).

Before: a [DataMember] public Guid MyId property shows a non-editable row displaying "Guid".
After: the value is editable as text with format guidance, auto-formatting and live feedback.

Related Issue

No linked issue — quality-of-life editor feature; Guid properties on user components were
previously impossible to set from Game Studio.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

Nicogo1705 and others added 5 commits July 19, 2026 15:08
Guid members on components/assets previously fell through to the read-only
ObjectPropertyTemplateProvider fallback and rendered as a non-editable
"Guid" row. Add a GuidPropertyTemplateProvider (TypeMatchTemplateProvider,
also covers Nullable<Guid>) mirroring the string editor: a TextBox bound
through a new GuidToString converter whose ConvertBack keeps the current
value (Binding.DoNothing) when the text does not parse as a Guid.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Follow-up to the Guid property editor: ConvertBack now passes invalid text
through instead of swallowing it with Binding.DoNothing — the typed node
setter throws InvalidCastException, TextBoxBase raises
TextToSourceValueConversionFailed, and the attached
TextBoxPropertyValueValidationBehavior (same pattern as the UFile editor)
plays the error adorner while the text reverts to the source value.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Two usability layers on the Guid property editor:
- GuidTemplateRemainder + a ghost TextBlock overlay: while the editor has
  focus, the typed prefix is completed with the remaining
  "0000...-0000" pattern in faint text, so the missing length and dash
  positions are visible at a glance. The typed part is rendered
  transparent purely to keep the remainder aligned.
- GuidInputMaskBehavior: hex input is regrouped live as 8-4-4-4-12 with
  dashes inserted automatically (caret hops past a freshly inserted dash).
  Deletions are not fought — backspacing a dash does not re-append it —
  and non-hex input is left for commit-time validation to flag.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The mask behavior sets MaxLength = 36 (32 hex + 4 dashes) so typing past a
complete Guid is rejected natively while selection replacement still works,
and strips brace/paren wrappers from pasted Guid forms.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
While typing, any non-hex content turns the editor text IndianRed
immediately (SetCurrentValue keeps styling intact; InvalidateProperty
restores it once the text is clean). Purely visual - input is neither
blocked nor rewritten, commit-time validation still does the hard reject.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Nicogo1705

Copy link
Copy Markdown
Contributor Author
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant