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

newValue argument as Ref for *Changing() generated methods #1054

Open
Gabboxl opened this issue Feb 25, 2025 · 0 comments
Open

newValue argument as Ref for *Changing() generated methods #1054

Gabboxl opened this issue Feb 25, 2025 · 0 comments
Labels
feature request 📬 A request for new changes to improve functionality

Comments

@Gabboxl
Copy link

Gabboxl commented Feb 25, 2025

Overview

Hi, I'm migrating some old C# ViewModel code to use the [ObservableProperty] attribute on all the properties.

I'd like to convert the following code:

private string _windowTitle;
public string WindowTitle {
  get {
    return _windowTitle;
  }
  set {
    _windowTitle = $ "Window title prefix: {value}";
    OnPropertyChanged(nameof(WindowTitle));
  }
}

...but I couldn't find any "simple" or "standard" method to accomplish the same behavior using the MVVM Toolkit.

I discovered that recently the methods *Changing(string? newValue) or *Changing(string? oldValue, string newValue) got added, but the newValue isn't passed as ref string, so I can't intercept and change the value.

Could this prototype be implemented for those methods? Thanks!

API breakdown

partial void OnWindowTitleChanging(ref string value);
partial void OnWindowTitleChanging(string? oldValue, ref string newValue);

Usage example

partial void OnWindowTitleChanging(string? oldValue, ref string newValue)
{
    newValue = "Window title prefix: " + newValue;
}

Breaking change?

I'm not sure

Alternatives

Additional context

No response

Help us help you

No, just wanted to propose this

@Gabboxl Gabboxl added the feature request 📬 A request for new changes to improve functionality label Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request 📬 A request for new changes to improve functionality
Projects
None yet
Development

No branches or pull requests

1 participant