I have a Silverlight application that uses a RadGridView control. When a user updates a value in the column, I would expect the sum to be updated. This behavior is shown on the Telerik demo site. I have a hunch that its my view-model. But, I’m not sure. Here is a snippet of my view, and the view-model.
View
<telerik:RadGridView>
<telerik:GridViewDataColumn Header="Column1" DataMemberBinding="{Binding Path=Tally[0], Mode=TwoWay}">
<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:SumFunction ResultFormatString="{}{0:N2}" SourceField="Tally[0]" />
</telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="Column2" DataMemberBinding="{Binding Path=Tally[1], Mode=TwoWay}">
<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:SumFunction ResultFormatString="{}{0:N2}" SourceField="Tally[1]" />
</telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="Column3" DataMemberBinding="{Binding Path=Tally[2], Mode=TwoWay}">
<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:SumFunction ResultFormatString="{}{0:N2}" SourceField="Tally[2]" />
</telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>
</telerik:RadGridView>
ViewModel
public class MyViewModel : ViewModel
{
private ObservableCollection<Item> items = Item.GetAll();
public ObservableCollection<Item> Items
{
get { return items; }
set {
items = value;
NotifyPropertyChanged("Items");
}
}
}
public class Item : ViewModel
{
private List<int> tally = new List<int>();
public List<int> Tally
{
get { return tally; }
set
{
tally = value;
NotifyPropertyChanged("Tally");
}
}
public Item()
{
for (int i = 0; i < 10; i++)
this.Tally.Add(i);
}
public static ObservableCollection<Item> GetAll()
{
ObservableCollection<Item> items = new ObservableCollection<Item>();
for (int i = 0; i < 10; i++)
items.Add(new Item(i));
return items;
}
}
Why is the total sum not being updated?
How if you change Tallt property of Item class to
and