private void UpdateScrolling() { if (SelectedItem == null) { return; } var p = SelectedItem.Widget.Bounds; var bounds = _box.ActualBounds; InternalChild.UpdateLayout(); var sz = new Point(InternalChild.Bounds.Width, InternalChild.Bounds.Height); var maximum = InternalChild.ScrollMaximum; p.X -= bounds.X; p.Y -= bounds.Y; var lineHeight = ListBoxStyle.ListItemStyle.LabelStyle.Font.FontSize; var sp = InternalChild.ScrollPosition; if (p.Y < sp.Y) { sp.Y = p.Y; } else if (p.Y + lineHeight > sp.Y + sz.Y) { sp.Y = (p.Y + lineHeight - sz.Y); } InternalChild.ScrollPosition = sp; }
private void UpdateScrolling() { if (SelectedItem == null) { return; } var p = SelectedItem.Bounds; var bounds = _box.ActualBounds; InternalChild.UpdateLayout(); var sz = new Point(InternalChild.Bounds.Width, InternalChild.Bounds.Height); p.X -= bounds.X; p.Y -= bounds.Y; var lineHeight = 20; var sp = InternalChild.ScrollPosition; if (p.Y < sp.Y) { sp.Y = p.Y; } else if (p.Y + lineHeight > sp.Y + sz.Y) { sp.Y = (p.Y + lineHeight - sz.Y); } InternalChild.ScrollPosition = sp; }