private void PileList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if ((int)e.Action == (int)NotifyCollectionChangedAction.Reset) { _thisStack !.Children.Clear(); // hopefully this simple (nothing else). well see return; } if ((int)e.Action == (int)NotifyCollectionChangedAction.Remove) { foreach (var thisItem in e.OldItems) { var thisPile = (BasicPileInfo <DutchBlitzCardInformation>)thisItem !; var thisCon = FindControl(thisPile); _thisStack !.Children.Remove(thisCon); } return; } if (e.Action == (int)NotifyCollectionChangedAction.Add) { foreach (var ThisItem in e.NewItems) { var thisPile = (BasicPileInfo <DutchBlitzCardInformation>)ThisItem !; IndividualPileXF thisCon = new IndividualPileXF(); thisCon.ThisPile = thisPile; thisCon.MainMod = _thisMod; thisCon.Init(); _thisStack !.Children.Add(thisCon); } return; } }
public void Init(PublicViewModel mod) { _thisMod = mod; _thisStack = new StackLayout(); var tempCard = new DutchBlitzCardInformation(); var thisP = Resolve <IProportionImage>(); HeightRequest = tempCard.DefaultSize.Height * thisP.Proportion; _thisStack.Orientation = StackOrientation.Horizontal; // start out horizontally _thisStack.HorizontalOptions = LayoutOptions.Start; _thisStack.VerticalOptions = LayoutOptions.Start; Grid grid = new Grid(); _drawControl = new SKCanvasView(); _drawControl.EnableTouchEvents = true; _drawControl.Touch += TouchEvent; _pileList = _thisMod.PileList; // i think its that simple. _pileList.CollectionChanged += PileList_CollectionChanged; foreach (var thisPile in _pileList) { IndividualPileXF thisCon = new IndividualPileXF(); thisCon.ThisPile = thisPile; thisCon.MainMod = _thisMod; thisCon.Init(); // i think i needed this as well _thisStack.Children.Add(thisCon); } grid.Children.Add(_drawControl); grid.Children.Add(_thisStack); Content = grid; }
public void UpdateLists(PublicViewModel mod) { _thisMod = mod; _thisStack !.Children.Clear(); //best to just redo this time. _pileList !.CollectionChanged -= PileList_CollectionChanged; _pileList = _thisMod.PileList; _pileList.CollectionChanged += PileList_CollectionChanged; foreach (var thisPile in _pileList) { IndividualPileXF thisCon = new IndividualPileXF(); thisCon.ThisPile = thisPile; thisCon.MainMod = _thisMod; thisCon.Init(); // i think i needed this as well _thisStack.Children.Add(thisCon); } }