OnPropertyChanged

Hello all,
can someone explain to me what is the sense of the generated method "OnPropertyChanged()" in all xxxx.razor.designer.cs code files

    public void OnPropertyChanged(PropertyChangedEventArgs args)
    {
    }

Can i use it somehow? Have i overseen something? Or is it a relict?
I dont understand the meaning of this method...

Thomas

It's an event that will be raised on every global property change:

Globals.PropertyChanged += OnPropertyChanged;

Hi @enchev,
and this method is called on every change of a page property:

    protected Trent.Models.Trentdb.Kalkulationsposition kalkulationsposition
    {
        get
        {
            return _kalkulationsposition;
        }
        set
        {
            if (!object.Equals(_kalkulationsposition, value))
            {
                var args = new PropertyChangedEventArgs(){ Name = "kalkulationsposition", NewValue = value, OldValue = _kalkulationsposition };
                _kalkulationsposition = value;
                **OnPropertyChanged(args);**
                Reload();
            }
        }
    }

    IEnumerable<Trent.Models.Trentdb.Artikel> _getArtikelsResult;
    protected IEnumerable<Trent.Models.Trentdb.Artikel> getArtikelsResult
    {
        get
        {
            return _getArtikelsResult;
        }
        set
        {
            if (!object.Equals(_getArtikelsResult, value))
            {
                var args = new PropertyChangedEventArgs(){ Name = "getArtikelsResult", NewValue = value, OldValue = _getArtikelsResult };
                _getArtikelsResult = value;
                **OnPropertyChanged(args);**
                Reload();
            }
        }
    }

And so on for every Page property...

But i cant put any custom code in there because the OnPropertyChange method is in the generated code.
Im looking for a place where i can react on a property change of form components. E.g. a click on a selectbar component that is bound to a database column. I need to react on the change of the bound property value.
And i think that OnPropertyChange is the right place. but i cant customize it.

Thomas

The place you are looking for is the page partial class.

Hello i need to intercept OnPropertyChanged in partial class.
Could you make a little example how to proceed?
Best regards

1 Like

I think this method should be partial too if you want to use the data of these events.

Hi @enchev,
are there any chance that RS will generate the OnPropertyChange Method as "partial" so that we can handle this event in our partial classes too?

Thomas

Hmmm... i think "partial" for OnPropertyChange cant be done.

Ok... i found no way to customize the OnPropertyChange method in the custom partial part of the page.

Thomas

You should handle the Change event instead.