This is a migrated thread and some comments may be shown as answers.

[Solved] ShowInsertRow row not responding to bound item propertychanged events

1 Answer 99 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Peran
Top achievements
Rank 1
Peran asked on 13 Jan 2011, 12:59 PM
I have a grid which is bound to a collection of Invoice objects (see demo Invoice class below). ShowInsertRow = True.

If I modify an existing row NetAmount cell (say to 100) and tab off the TaxAmount & GrossAmount cells are updated. i.e. those cells are responding to the Invoice PropertyChanged events.

If I perform the same action on the 'click here to add new item' row the TaxAmount & GrossAmount cells do not respond to the Invoice PropertyChanged events.  The cells remain with a value of '0' until you tab into the cell when the value changes to be correct.

I have a demo project to demonstrate the issue.



using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
 
namespace RadControlsSilverlightApp1
{
    using System.ComponentModel;
 
    public class Invoice : System.ComponentModel.INotifyPropertyChanged
    {
        private decimal netAmount = 0m;
 
        public decimal NetAmount
        {
            get
            {
                return this.netAmount;
            }
 
            set
            {
                if (value != this.netAmount)
                {
                    this.netAmount = Math.Round(value, 2);
                    OnPropertyChanged("NetAmount");
                }
            }
        }
 
        private decimal taxAmount = 0m;
 
        public decimal TaxAmount
        {
            get
            {
                return this.taxAmount;
            }
 
            set
            {
                if (value != this.taxAmount)
                {
                    this.taxAmount = Math.Round(value, 2);
                    OnPropertyChanged("TaxAmount");
                }
            }
        }
 
        private decimal grossAmount = 0m;
 
        public decimal GrossAmount
        {
            get
            {
                return this.grossAmount;
            }
 
            set
            {
                if (value != this.grossAmount)
                {
                    this.grossAmount = Math.Round(value, 2);
                    OnPropertyChanged("GrossAmount");
                }
            }
        }
 
 
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
 
        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
 
            if (propertyName == "NetAmount")
            {
                //this.taxAmount = Math.Round(this.netAmount * 0.20m);
                //this.grossAmount = Math.Round(this.netAmount + this.taxAmount);
 
                //// refresh UI
                //OnPropertyChanged(string.Empty);
 
                this.TaxAmount = this.NetAmount * 0.20m;
                this.GrossAmount = this.NetAmount + this.TaxAmount;
            }
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Peran
Top achievements
Rank 1
answered on 14 Jan 2011, 01:36 PM
The issues has been resolved when I tested using the latest hotfix dll's.
Tags
GridView
Asked by
Peran
Top achievements
Rank 1
Answers by
Peran
Top achievements
Rank 1
Share this question
or