fix:Row错误行数、高度导致响应式布局不生效,具体表现为第一次渲染时容器高度计算错误,鼠标移入控件时触发布局更新,高度才正常#1762
Open
y60024651 wants to merge 2 commits intoHandyOrg:masterfrom
Open
fix:Row错误行数、高度导致响应式布局不生效,具体表现为第一次渲染时容器高度计算错误,鼠标移入控件时触发布局更新,高度才正常#1762y60024651 wants to merge 2 commits intoHandyOrg:masterfrom
y60024651 wants to merge 2 commits intoHandyOrg:masterfrom
Conversation
…Infinity 作为其 DesiredSize 返回,即使将 Infinity 作为可用大小传入。请基于Row目前有的代码解决这个告警问题
Member
|
@y60024651 看了下,感觉只要再 MeasureOverride 方法开头加一行 _layoutStatus = ColLayout.GetLayoutStatus(constraint.Width); 就能解决了,你确认下呢? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
失败原因:
父容器 (StackPanel)
↓
调用 Row.Measure(constraint)
constraint.Width = Infinity ❌
|
├─ 未设置 _layoutStatus (为 null)
├─ 子控件 Measure() 用错误的列数计算宽度
├─ Row 返回过大的 Height (假设两倍)
↓
Row.Arrange(finalSize)
├─ 这里才设置 _layoutStatus ✅
├─ 但高度已被父容器缓存,未重新计算 ❌
↓
渲染结果:首帧高度过高 → 出现多余空白
鼠标移入(触发布局刷新)
↓
重新执行 Measure/Arrange
constraint.Width 已确定
_layoutStatus 正确
↓
高度恢复正常 ✅
修复方法:
父容器 (StackPanel)
↓
调用 Row.Measure(constraint)
constraint.Width = Infinity
|
├─ 检测到 Infinity → 用 parent.ActualWidth 替代 ✅
├─ 即使父未渲染,也安排 Dispatcher.BeginInvoke(InvalidateMeasure) 延迟重测 ✅
├─ 当宽度可用时,localLayoutStatus = ColLayout.GetLayoutStatus(width) ✅
├─ 子控件正确测量,Row 得出准确高度 ✅
↓
Row.Arrange(finalSize)
├─ 使用同样 layoutStatus
├─ 正常布局所有列 ✅
↓
首帧渲染就正确无空白 ✅