未验证 提交 c49a155c 编写于 作者: D David 提交者: GitHub

Merge pull request #12055 from unoplatform/dev/dr/calendarFix

fix: Fix calendar header display first selectable month instead of current
......@@ -345,6 +345,7 @@ namespace Windows.UI.Xaml.Controls.Primitives
private CalendarLayoutStrategy? _layoutStrategy;
private CalendarViewGeneratorHost? _host;
private Rect _effectiveViewport;
private bool _hasEffectiveViewport;
private Rect _lastLayoutedViewport = Rect.Empty;
private void base_Initialize()
......@@ -742,6 +743,13 @@ namespace Windows.UI.Xaml.Controls.Primitives
private void OnEffectiveViewportChanged(EffectiveViewportChangedEventArgs args)
{
if (_hasEffectiveViewport && args.EffectiveViewport.IsEmpty)
{
// The panel is not visible at all, don't update the _effectiveLayout so any measure/arrange path would keep the current values.
// This also prevent a useless InvalidateMeasure() that causes lags but also implicit scroll (and header update) to the January 19XX.
return;
}
_effectiveViewport = args.EffectiveViewport;
if (_host is null || _layoutStrategy is null)
......@@ -750,7 +758,10 @@ namespace Windows.UI.Xaml.Controls.Primitives
}
var needsMeasure = ForceConfigViewport(GetLayoutViewport().Size);
if (needsMeasure || Math.Abs(_effectiveViewport.Y - _lastLayoutedViewport.Y) > (_lastLayoutedViewport.Height / Rows) * .75)
_hasEffectiveViewport = true;
if (!args.EffectiveViewport.IsEmpty
&& (needsMeasure || Math.Abs(_effectiveViewport.Y - _lastLayoutedViewport.Y) > (_lastLayoutedViewport.Height / Rows) * .75))
{
InvalidateMeasure();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册