Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First-class support for init-only records in XAML #18191

Open
maxkatz6 opened this issue Feb 14, 2025 · 0 comments
Open

First-class support for init-only records in XAML #18191

maxkatz6 opened this issue Feb 14, 2025 · 0 comments

Comments

@maxkatz6
Copy link
Member

maxkatz6 commented Feb 14, 2025

Is your feature request related to a problem? Please describe.

Let's say we have a record defined as public record Model(int PropA, string PropB).
Currently developers have to use rather verbose syntax with x:Arguments, specifying each parameter ctor independently.

Describe the solution you'd like

Since this record is well defined in IL metadata via modreq(IsExternalInit) we can match these properties with type constructor, and include automatically transform into a proper constructor call using XML property attributes as parameters.

IntelliSense shouldn't be a problem, since these ctor parameters are already defined as mutable properties, making them visible for auto-completion engine.

Bindings won't be possible in this solution. Even if it's technically possible to setup binding for an init-only property, what would we do with initial ctor values?

Additional context

It's not a commonly used pattern with XAML apps. But can be well considered into complex custom controls. Something I thought from this example #18189.

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

No branches or pull requests

1 participant