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

Proposal: Bring C# 9 "Init-Only" properties to XAML #2519

Open
ryandemopoulos opened this issue May 21, 2020 · 2 comments
Open

Proposal: Bring C# 9 "Init-Only" properties to XAML #2519

ryandemopoulos opened this issue May 21, 2020 · 2 comments
Assignees
Labels
feature proposal New feature proposal needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) team-Markup Issue for the Markup team

Comments

@ryandemopoulos
Copy link
Member

Proposal: C# 9 "Init-Only" properties in XAML

Init-only properties are a set-on-initialization-only accessor in C# 9. Morten has suggested that we bring this to XAML: https://twitter.com/dotMorten/status/1263284520364564481

Interesting idea to explore. It would allow the instantiation of read-only / immutable values in XAML markup.

Summary

Unsure if this would require a syntax change/expansion in XAML...?

Rationale

(it would be great if Morten or others could articulate additional rationale & scenarios here--I'm just blitzing Twitter notifications right now so doing light initial job on this proposal)

  • {First reason for why we should consider this proposal}
  • {Second reason for why we should consider this proposal}
  • {etc}

Scope

Capability Priority
This proposal will allow developers to accomplish W Must
This proposal will allow end users to accomplish X Should
This proposal will allow developers to accomplish Y Could
This proposal will allow end users to accomplish Z Won't

Important Notes

Open Questions

@ryandemopoulos ryandemopoulos added the feature proposal New feature proposal label May 21, 2020
@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label May 21, 2020
@ryandemopoulos ryandemopoulos added the needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) label May 21, 2020
@MikeHillberg
Copy link
Contributor

Big fan of this. The Xaml 2009 spec has an x:Arguments syntax for this, allowing you to pass arguments to the constructor:

https://docs.microsoft.com/en-us/dotnet/desktop-wpf/xaml-services/xarguments-directive

@ranjeshj ranjeshj added team-Markup Issue for the Markup team and removed needs-triage Issue needs to be triaged by the area owners labels May 27, 2020
@Trolldemorted
Copy link

Trolldemorted commented Aug 9, 2023

Are there any workarounds for this execpt "go through all your dataclasses and remove the immutability"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature proposal New feature proposal needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

5 participants