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

IndexOutOfRangeException when adding new rows

2 Answers 149 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sebastian
Top achievements
Rank 1
Sebastian asked on 12 Aug 2011, 12:33 PM
Hi,
when I am using an observable collection of the following class as ItemsSource for the datagrid I get an exception when  I add a new Row (via UI, ShowInsertRow is enabled) and the row is commited.

ArgumentOutOfRangeException: "Specified argument was out of the range of valid values. Parameter name: index".
Source: "Telerik.Windows.Data"
Stacktrace: "bei Telerik.Windows.Data.QueryableCollectionView.GetItemAt(Int32 index) in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:Zeile 1766."
File Version of Telerik.Windows.Controls.GridView.dll is 2011.2.712.40.

This happens only when binding a list of ParameterView. ViewModelBase just implements INotifyPropertyChanged.
public class ParameterView : ViewModelBase<ParameterView>
{
    private string _name;
    public string Name
    {
        get { return _name; }
        set { _name = value; Notify(x => x.Name);}
    }
  
    private string _value;
    public string Value
    {
        get { return _value; }
        set { _value = value; Notify(x => x.Value); }
    }
  
    public ParameterView() : this(string.Empty,string.Empty)
    {
    }
  
    public ParameterView(string name, string value)
    {
        Name = name;
        Value = value;
    }
  
    public override string ToString()
    {
        return string.Format("Name: {0}, Value: {1}", _name, _value);
    }
  
    public bool Equals(ParameterView other)
    {
        if (ReferenceEquals(null, other)) return false;
        if (ReferenceEquals(this, other)) return true;
        return Equals(other._name, _name);
    }
  
    public override bool Equals(object obj)
    {
        if (ReferenceEquals(null, obj)) return false;
        if (ReferenceEquals(this, obj)) return true;
        if (obj.GetType() != typeof(ParameterView)) return false;
        return Equals((ParameterView)obj);
    }
  
    public override int GetHashCode()
    {
        unchecked
        {
            return ((_name != null ? _name.GetHashCode() : 0) * 397) ^ (_value != null ? _value.GetHashCode() : 0);
        }
    }
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 12 Aug 2011, 02:12 PM
Hello Sebastian,

 May you please check whether you are reproducing the problem with the binaries from the latest internal build?

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Sebastian
Top achievements
Rank 1
answered on 12 Aug 2011, 02:52 PM
The current version works, thank you.
Tags
GridView
Asked by
Sebastian
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Sebastian
Top achievements
Rank 1
Share this question
or