Giter Site home page Giter Site logo

Comments (6)

SSchulze1989 avatar SSchulze1989 commented on May 23, 2024 1

Thank you very much for the quick response and the change.
Exactly what i needed and working like a charm!

from mvvmblazor.

SSchulze1989 avatar SSchulze1989 commented on May 23, 2024

To elaborate, i was looking for something less verbose than:

public string Name
    {
        get => _model.Name;
        set
        {
            _model.Name = value;
            OnPropertyChanged(nameof(Name));
        }
    }

On top of that, could the

[CallerMemberName]

attribute also be added to OnPropertyChanged Method, so i can at least just write

OnPropertyChanged()

?

from mvvmblazor.

klemmchr avatar klemmchr commented on May 23, 2024

Currently there is no built-in solution for this. Could you elaborate why you want a binding on a sub model? Is the model changed externally outside of the view model?

from mvvmblazor.

SSchulze1989 avatar SSchulze1989 commented on May 23, 2024

The Model is part of my Business Logic that communicates with a REST Api. The ViewModel should enable modifying the Model and then sending a request back to the Api without having to map in between the models.

from mvvmblazor.

klemmchr avatar klemmchr commented on May 23, 2024

This could only be achieved by having a binding on a type that implements INotifyPropertyChanged and then listen to changed events on this end. Would be a new feature and possibly be a bit tedious to implement because it would break with current behavior. Would that suit you?

from mvvmblazor.

SSchulze1989 avatar SSchulze1989 commented on May 23, 2024

Ah I think i did not get that across correctly.
I do not want the Model to notify on the ViewModel. The ViewModel would still invoke the notification itself but the changes should be reflected on the Model so that the Business logic can handle the requests.

So I want the Model to hold the state for the api client and the ViewModel for interaction with the component.
I updated my code example a little so maybe it gets clearer.
In the end I think I can do with what I have shown in the example if there is not a build in way to deal with it.

Would it still be possible to add [CallerMemberName] to the OnPropertyChanged() Method?

from mvvmblazor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.