Vinay Dwivedi
Vinay Dwivedi

Reputation: 767

How to handle WPF Cyclic property updates - MVVM?

for example following 2 properties

public Decimal TradedDelta
        {
            get { return _confirmation.DeltaPercent; }
            set { 
                _confirmation.DeltaPercent = value;
                DeltaShareCount = ApplicationHelper.GetPercentValue(Multiplier * Size, value, AppConstants.BROKERHUB_ROUNDING_VAL);
                OnPropertyChanged("TradedDelta"); 
            }
        }

        public Decimal DeltaShareCount
        {
            get { return _confirmation.DeltaShares; }
            set
            {
                _confirmation.DeltaShares = value;
                TradedDelta = ApplicationHelper.GetPercentOF(value, Multiplier * Size, AppConstants.BROKERHUB_ROUNDING_VAL);
                OnPropertyChanged("DeltaShareCount");
            }
        }

Upvotes: 0

Views: 108

Answers (1)

Rohit Vats
Rohit Vats

Reputation: 81253

You have to check that yourself by putting equality check on your property setters. WPF can't handle that for you.

    public Decimal TradedDelta
    {
        get { return _confirmation.DeltaPercent; }
        set { 
             if(_confirmation.DeltaPercent != value) <-- HERE
             {
                 _confirmation.DeltaPercent = value;
                 DeltaShareCount = ApplicationHelper.GetPercentValue(
                Multiplier * Size, value, AppConstants.BROKERHUB_ROUNDING_VAL);
                 OnPropertyChanged("TradedDelta");
             }
        }
    }

Upvotes: 3

Related Questions