private void Splitter_Dragged(DraggableSeparator sender, double x, double y, double dx, double dy) { var curPos = (Orientation == StackOrientation.Vertical ? y : x); var newPos = _lastPos - curPos; if (Math.Abs(newPos) < MinDragLength) { return; } _lastPos = curPos; if (!(sender.Parent is ResizableStackLayout resizableLayout)) { return; } var layout = (Layout <View>)resizableLayout; var diff = Math.Sign(newPos); var index = base.Children.IndexOf(sender); if (index <= 0 || index + 1 >= layout.Children.Count) { Debug.WriteLine("ResizableStackLayout: Illegal index - should never be here."); return; } var leftChild = layout.Children[index - 1]; var rightChild = layout.Children[index + 1]; DiffWeight(leftChild, rightChild, diff); }
private void InsertMissingSeparators() { var missingSeparators = new List <int>(); for (var i = 1; i < Children.Count; i++) { if (base.Children[i - 1] is DraggableSeparator) { continue; } if (!(base.Children[i] is DraggableSeparator)) { missingSeparators.Add(i); } } IEnumerable <int> en = missingSeparators; foreach (var index in en.Reverse()) { var sep = new DraggableSeparator { Orientation = Orientation }; //TODO: handle removing these elements when the page is closed sep.DragStart += Splitter_DragStart; sep.Dragged += Splitter_Dragged; base.Children.Insert(index, sep); } }
private void Splitter_DragStart(DraggableSeparator sender, double x, double y) { _lastPos = Orientation == StackOrientation.Vertical ? y : x; }