public static void AdjustFirstItem(int newIdx, SimpleData 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() { Dx = new ObservableCollection <SimpleData>(); SimpleData Sd; Sd = new SimpleData(0, "Uno", 100.1, 201.1, 1001, 2001); Sd.PropertyChanged += Sd_PropertyChanged; Dx.Add(Sd); Sd = new SimpleData(1, "Dos", 100.2, 201.2, 1002, 2002); Sd.PropertyChanged += Sd_PropertyChanged; Dx.Add(Sd); Sd = new SimpleData(2, "Tres", 100.3, 201.3, 1003, 2003); Sd.PropertyChanged += Sd_PropertyChanged; Dx.Add(Sd); }
// proof of concept. using a delegate to define a method that // modifies each element in the collection public static void AdjustMiddleItems(int newIdx, SimpleData currentSd, SimpleData 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, SimpleData currentSd, SimpleData priorSd) { AdjustMiddleItems(newIdx, currentSd, priorSd); currentSd.PropertyS = "last " + currentSd.PropertyS; }