mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-16 21:21:03 +08:00
Merge remote-tracking branch 'origin/release/6.0' into release/6.0
This commit is contained in:
+1
-1
@@ -47,7 +47,7 @@
|
||||
<gallery:ShowCasePanel Name="ExamplesContent"
|
||||
IsScrollEnabled="False"
|
||||
IsDeferredLoadingEnabled="True"
|
||||
InitialDeferredLoadItemCount="4"
|
||||
InitialDeferredLoadItemCount="1"
|
||||
DeferredLoadBatchSize="2"
|
||||
MaxColumns="1"
|
||||
ContentMargin="28,10,28,28">
|
||||
|
||||
@@ -143,6 +143,7 @@ public class ShowCasePanel : TemplatedControl
|
||||
- 新挂载、恢复可见或不再占满整行的 item 在首次重新进入普通布局时放入当前最短列。
|
||||
- 有效列数变化时清除旧列假设,并按当前最短列重新建立全部归属。
|
||||
- `ShowCaseItemSpan.Full` 或 `IsOccupyEntireRow=true` 占满整行,不进入普通列归属。
|
||||
- 测量与实际排列宽度不同时,按排列宽度重新测量子项,并在输入测量宽度不变的后续布局中沿用该宽度,避免分数缩放下重复失效;输入宽度变化或脱离视觉树时清除该记录。
|
||||
- 不做虚拟化,只负责已挂载 children 的测量和排列。
|
||||
|
||||
该面板保持简单,不引入 ItemsControl、ItemsSource 或数据模板。ShowCase 页面是文档式页面,不是无限列表。
|
||||
|
||||
@@ -23,6 +23,8 @@ public class ShowCaseMasonryPanel : Panel
|
||||
private double _measuredEffectiveWidth;
|
||||
private int _measuredChildCount;
|
||||
private bool _hasMeasuredLayout;
|
||||
private double _previousAvailableWidth = double.NaN;
|
||||
private double? _arrangedEffectiveWidth;
|
||||
private readonly Dictionary<Control, int> _stableColumns = new(ReferenceEqualityComparer.Instance);
|
||||
private int _stableColumnCount;
|
||||
private bool _hasStableAssignments;
|
||||
@@ -62,7 +64,16 @@ public class ShowCaseMasonryPanel : Panel
|
||||
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
var layout = CalculateLayout(availableSize.Width, true);
|
||||
if (_previousAvailableWidth != availableSize.Width)
|
||||
{
|
||||
_arrangedEffectiveWidth = null;
|
||||
}
|
||||
_previousAvailableWidth = availableSize.Width;
|
||||
// Ancestor layout rounding can give us a different final width even when the
|
||||
// measure constraint is unchanged. Reuse that width on the follow-up measure
|
||||
// so arrange-time child measurement does not invalidate us on every pass.
|
||||
var effectiveWidth = _arrangedEffectiveWidth ?? ResolveAvailableWidth(availableSize.Width);
|
||||
var layout = CalculateLayout(effectiveWidth, true);
|
||||
_measuredLayout = layout;
|
||||
_measuredEffectiveWidth = layout.Width;
|
||||
_measuredChildCount = Children.Count;
|
||||
@@ -74,6 +85,7 @@ public class ShowCaseMasonryPanel : Panel
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
var effectiveWidth = ResolveAvailableWidth(finalSize.Width);
|
||||
_arrangedEffectiveWidth = effectiveWidth;
|
||||
var canReuseMeasuredLayout = _hasMeasuredLayout &&
|
||||
_measuredChildCount == Children.Count &&
|
||||
AreClose(_measuredEffectiveWidth, effectiveWidth);
|
||||
@@ -101,6 +113,8 @@ public class ShowCaseMasonryPanel : Panel
|
||||
{
|
||||
_hasMeasuredLayout = false;
|
||||
_measuredLayout = null;
|
||||
_previousAvailableWidth = double.NaN;
|
||||
_arrangedEffectiveWidth = null;
|
||||
ClearStableAssignments();
|
||||
base.OnDetachedFromVisualTree(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user