tags:

views:

67

answers:

4

My textbox is the only control on a window, which is a part of a bigger application. The textbox contains a certain amount of text, large enough to show vertical scrollbar. The scrollbar appears, but without a thumb:

alt text

I can still scroll the contents, either with mouse wheel or by clicking the arrow-buttons repeatedly. When I create a new project with the same window and textbox the scrollbar works as it should. The same happens with a WrapPanel. Do you have ideas what could be spoiling my existing project and causing this issue? In generic.xaml I found some styles overriding the defaults for scrollbar and scrollviewer, but even totally clearing generic.xaml didn't help.

Thanks in advance!

EDIT: right, sorry, totally forgot about the code. It's XAML only (no c# backing code).

<Window x:Class="TextBoxTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" MaxHeight="200" MaxWidth="200">
<TextBox x:Name="textbox" MaxLines="2"  MaxHeight="50" VerticalScrollBarVisibility="Auto" TextWrapping="WrapWithOverflow">
    Useless text..... asdasdasda ssssssssssssss sssssss ssssaokdoka sdojwoandowm nxaofwha398ua ozmca3u0a3j3   a80a9fu 03 u0sf u0s9jf4s 0cuj wuf0j w40 fcjw cujwfj9 c9 u49 wsuc j9w3
    3089w 9f8u4wfv 0sf ufw0u w0fuw0 fwu f0uw 09djcazp zopf h43 wofh FYHFWFH WOWY HWO H wohg fujg 4g fugj 4 g0 4
    4w fw4 f3f g555u45y 55 some more some moresome more some moresome more some moresome more some moresome more some more.
</TextBox>
</Window>
A: 

At a guess: your TextBox is inside a StackPanel. If you want more than a guess, you'll need to provide code.

HTH,
Kent

Kent Boogaart
Originally it was in a DockPanel, so I believed it was the problem, but the simple XAML window I inserted in my first post has the same defect.
rook
+1  A: 

It seems like a style problem. Remove explicit style setter from the TextBox (check both XAML and code behind). If TextBox has no explicit style, search for implicit styles (defined via TargetType="TextBox" or TargetType="{x:Type TextBox}" and/or x:Key="{x:Type TextBox"}).

Try snooping your application and check ScrollViewer's visual tree. It may give you some insights where to look.

Hope this helps.

Anvaka
Very nice utility, thanks! I tried to 'snoop' both applications (the app with not working scrollbar and the new project, where the textbox works). Really interesting thing is that scrollbars in the Snoop window were also spoilt, when debugging the "spoilt" application. It didn't occur in the latter case.
rook
A: 

Did you set your textbox Multiline to true?

Wildhorn
There is no such property in WPF (unlike in WindowsForms). There is TextWrapping property instead.
rook
A: 

The answer is astonishing!

Just after I'd started to suspect it might be a WPF bug, I found this forum thread. Guy who asked the question says: "My application uses a directx renderer from a DLL that's written in C++". Mine does almost the same with the difference that my renderer is written in C# (MDX) and uses D3DImage interop.

Following steps mentioned in the thread above, I moved DirectX initialization from OnInitialize() to Loaded event callback of the main window and now scrollbars regained their expected appearance. It seems that GUI must be displayed first, before the renderer is initialized.

So I guess it's reasonable to talk about a bug in this case.

rook