public void SetHorizontalOffset(double offset) { if (offset < 0 || this.viewport.Width >= this.extent.Width) { offset = 0; } else if (offset + this.viewport.Width >= this.extent.Width) { offset = this.extent.Width - this.viewport.Width; } this.contentOffset.X = offset; if (usingCustomScrolling) { this.horizontalBackend.SetOffset(offset); } else { this.transform.X = -offset; } if (ScrollOwner != null) { ScrollOwner.InvalidateScrollInfo(); } }
private void SetViewport(Size size) { if (_viewport != size) { _viewport = size; if (_owner != null) { _owner.InvalidateScrollInfo(); } } }
void SetOffset(double?x = null, double?y = null) { var offset = this.contentOffset; if (x.HasValue) { offset.X = x.Value; } if (y.HasValue) { offset.Y = y.Value; } // Clamp horizontal if (offset.X < 0 || this.viewport.Width >= this.extent.Width) { offset.X = 0; } else if (offset.X + this.viewport.Width >= this.extent.Width) { offset.X = this.extent.Width - this.viewport.Width; } // Clamp vertical if (offset.Y < 0 || this.viewport.Height >= this.extent.Height) { offset.Y = 0; } else if (offset.Y + this.viewport.Height >= this.extent.Height) { offset.Y = this.extent.Height - this.viewport.Height; } if (offset != this.contentOffset) { this.contentOffset = offset; if (usingCustomScrolling) { this.horizontalBackend.SetOffset(offset.X); this.verticalBackend.SetOffset(offset.Y); } else { this.transform.X = -offset.X; this.transform.Y = -offset.Y; } if (ScrollOwner != null) { ScrollOwner.InvalidateScrollInfo(); } } }
// OnScrollChange is an override called whenever the IScrollInfo exposed scrolling state changes on this element. // At the time this method is called, scrolling state is in its new, valid state. private void OnScrollChange() { if (ScrollOwner != null) { ScrollOwner.InvalidateScrollInfo(); } }