gpt4 book ai didi

当 UseLayoutRounding ="True"时,WPF 陷入无限循环

转载 作者:行者123 更新时间:2023-12-04 12:41:30 24 4
gpt4 key购买 nike

UIElement.UseLayoutRounding="True" 时,我遇到了在 .NET 4.0 上重现的问题和 TextBoxBase.VerticalScrollBarVisibility="Auto"设置在一起。
该问题仅在 Windows 经典主题上重现(在 Windows 7 和 XP 上测试)。

当窗口被加载时,WPF 在无限循环中显示然后隐藏 TextBlock 上的垂直滚动条,从而使 UI 变得不可用。

标记非常简单:
App.xaml :

<Application x:Class="PhysioControl.CodeStat.UI.Reviewer.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindowView.xaml"/>
MainWindowView.xaml :
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
UseLayoutRounding="True">
<StackPanel>
<TextBox VerticalScrollBarVisibility="Auto"/>
</StackPanel>
</Window>

有没有人对避免这种情况的方法有任何想法?

最佳答案

TextBoxView 中发生了一些非常时髦的事情,.NET 4.5 的引用源文档错误号 1766924,带有一个补丁,可以禁用 VerticalScrollBarVisibility=Auto 的背景布局计算。引用:

        // Workaround for bug 1766924.
// When VerticalScrollBarVisiblity == Auto, there's a problem with
// our interaction with ScrollViewer. Disable background layout to
// mitigate the problem until we can take a real fix in v.next.
//

这似乎与此有关 feedback article这描述了您的确切观察结果。

.NET 4.0 中的已知问题,已在 4.5 中修复。要求遇到此问题的用户在他们的机器上安装 .NET 4.5。如果您需要让 XP 用户满意,请注意 rfboilers 提出的解决方法。

关于当 UseLayoutRounding ="True"时,WPF 陷入无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18017068/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com