fix: SectionPanel resizing

This commit is contained in:
2026-03-05 07:36:17 +03:00
parent a2f99cc376
commit fe46722d55
+6 -8
View File
@@ -94,7 +94,6 @@ public class SectionPanel : Panel
private readonly Dictionary<Control, int> _childIndeces = new Dictionary<Control, int>();
private bool _initialized = false;
private int _previousIndex = 0;
private bool _isChangingIndex = false;
public SectionPanel()
: base()
@@ -105,7 +104,6 @@ public class SectionPanel : Panel
return;
panel.CanScrollBackward = panel.Cyclic || panel.CurrentIndex != 0;
panel.CanScrollForward = panel.Cyclic || panel.CurrentIndex != panel.Children.Count() - 1;
_isChangingIndex = true;
panel.InvalidateArrange();
});
ChildrenSourceProperty.Changed.AddClassHandler<SectionPanel>((panel, ea) =>
@@ -309,21 +307,21 @@ public class SectionPanel : Panel
_initialized = true;
}
if (!_isChangingIndex)
if (_previousIndex == CurrentIndex)
{
foreach (var (child, i) in _childIndeces)
{
var rect = Orientation switch
{
Orientation.Vertical => new Rect(0, (i - _previousIndex) * finalSize.Height, finalSize.Width, finalSize.Height),
Orientation.Horizontal => new Rect((i - _previousIndex) * finalSize.Width, 0, finalSize.Width, finalSize.Height),
Orientation.Vertical => new Rect(0, i * finalSize.Height, finalSize.Width, finalSize.Height),
Orientation.Horizontal => new Rect(i * finalSize.Width, 0, finalSize.Width, finalSize.Height),
_ => default
};
child.Arrange(rect);
}
if (Children.Count() > 1)
}
else if (Children.Count() > 1)
Dispatcher.UIThread.Post(async () => _ = ApplyOffset(finalSize, true), DispatcherPriority.Render);
_isChangingIndex = false;
return finalSize;
}