public static void AdjustFirstItem(int newIdx, SimpleData3 currentSd) { propertyD1 += newIdx; propertyD2 += newIdx; propertyI1 += newIdx; propertyI2 += newIdx; currentSd.Index = newIdx; currentSd.PropertyS += ((char)('!' + newIdx)).ToString(); currentSd.PropertyD1 = propertyD1; currentSd.PropertyD2 = propertyD2; currentSd.PropertyI1 = propertyI1; currentSd.PropertyI2 = propertyI2; }
private void LoadData2() { Dx3 = new ObservableCollection <SimpleData3>(); SimpleData3 Sd3; Sd3 = new SimpleData3(0, "Uno", 100.1, 201.1, 1001, 2001); Sd3.PropertyChanged += Sd_PropertyChanged; Dx3.Add(Sd3); Sd3 = new SimpleData3(1, "Dos", 100.2, 201.2, 1002, 2002); Sd3.PropertyChanged += Sd_PropertyChanged; Dx3.Add(Sd3); Sd3 = new SimpleData3(2, "Tres", 100.3, 201.3, 1003, 2003); Sd3.PropertyChanged += Sd_PropertyChanged; Dx3.Add(Sd3); }
// proof of concept. using a delegate to define a method that // modifies each element in the collection public static void AdjustMiddleItems(int newIdx, SimpleData3 currentSd, SimpleData3 priorSd) { Debug.WriteLine("(before) Index| " + currentSd.Index + " name| " + currentSd.PropertyS); currentSd.Index = newIdx; if (priorSd == null) { Debug.WriteLine(" (after) Index| is null\n"); return; } currentSd.PropertyS += ((char)('!' + newIdx)).ToString(); currentSd.PropertyD1 = priorSd.PropertyD1 + newIdx; currentSd.PropertyD2 = priorSd.PropertyD2 + newIdx; currentSd.PropertyI1 = priorSd.PropertyI1 + newIdx; currentSd.PropertyI2 = priorSd.PropertyI2 + newIdx; Debug.WriteLine(" (after) Index| " + currentSd.Index + " name| " + currentSd.PropertyS + "\n"); }
public static void AdjustLastItem(int newIdx, SimpleData3 currentSd, SimpleData3 priorSd) { AdjustMiddleItems(newIdx, currentSd, priorSd); currentSd.PropertyS = "last " + currentSd.PropertyS; }