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

E.S*_*.S. 7 wpf xaml .net-4.0 visual-studio-2010

我面临着.NET 4.0,当再现问题UIElement.UseLayoutRounding="True",并TextBoxBase.VerticalScrollBarVisibility="Auto"设置在一起.该问题仅在Windows Classic主题(在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"/>
Run Code Online (Sandbox Code Playgroud)

MainWindowView.xaml:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        UseLayoutRounding="True">
    <StackPanel>
        <TextBox VerticalScrollBarVisibility="Auto"/>
    </StackPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)

有没有人有任何想法避免这种想法?

Han*_*ant 5

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.
        //
Run Code Online (Sandbox Code Playgroud)

这似乎与此反馈文章有关,该文章描述了您的确切观察结果.

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