WPF enters an endless loop when UseLayoutRounding = "True"

I ran into a problem reproduced on .NET 4.0 when UIElement.UseLayoutRounding="True" and TextBoxBase.VerticalScrollBarVisibility="Auto" set together. The problem is reproduced only on the Windows Classic theme (tested on Windows 7 and XP).

When the window loads, WPF shows and then hides the vertical scroll bar in the TextBlock in an infinite loop, so that the user interface becomes unusable.

The markup is completely simple:

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> 

Does anyone have any ideas on ways to avoid this?

+7
visual-studio-2010 wpf xaml
source share
3 answers

There is something very frightened about in TextBoxView, in Reference Source document for .NET 4.5, bug No. 1766924 with a patch that disables background layout calculation for VerticalScrollBarVisibility = Auto. Citation:

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

This seems to be related to this feedback article that describes your accurate observation.

Known issue in .NET 4.0 fixed in 4.5. Ask users with this problem to install .NET 4.5 on their computer. Pay attention to the workaround offered by rfboilers if you need XP users to be satisfied.

+4
source share

Perhaps this is due to the Stackpanel. The scroll viewer will lose visualization when it is inside the stack pane.

-one
source share

Have you made a “clean project” or “clean decision” in a visual studio? sometimes something in assemblies gets confused

-one
source share

All Articles