I have the following style defined in my App.xaml
<Style x:Key="textBoxMultiline" TargetType="{x:Type TextBox}" > <Setter Property="VerticalScrollBarVisibility" Value="Auto" /> <Setter Property="HorizontalScrollBarVisibility" Value="Hidden" /> <Setter Property="MinHeight" Value="50" /> <Setter Property="TextWrapping" Value="Wrap" /> </Style>
And in the whole solution, we use it in every text field that needs a short text.
<TextBox x:Name="textBoxDescription" Grid.Row="2" Grid.Column="1" Style="{DynamicResource textBoxMultiline}" />
Everything works fine, but then the client complains that some fields were set on older monitors with lower resolution, so I placed the ScrollViewer on one of the higher nodes of the visual tree to prevent snapping.
<ScrollViewer Height="Auto" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"> ... </ScrollViewer>
It is strange that TextBox es with the above style begin to expand to the right, instead of wrapping the text.
Is there a way to prevent this without ScrollViewer ?
dcarneiro
source share