Hns
Hns

Reputation: 11

Strange TextBox behavior in Windows 8.1 and windows 10

The following code works like expected in Windows 7:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="WpfApplication2.MainWindow"
    Title="MainWindow"
    Height="Auto"
    Width="500"
    ResizeMode="NoResize"
    WindowStyle="SingleBorderWindow" 
    SizeToContent="Height" 
    WindowStartupLocation="CenterScreen">
<Grid>
    <TextBox IsReadOnly="True"
             MinLines="6"
             MaxLines="6" 
             TextWrapping="Wrap"
             VerticalScrollBarVisibility="Visible"
             Text="test &#10;test &#10;test &#10;test &#10;test &#10;test &#10;test &#10;test &#10;test &#10;"/>
</Grid>

The same code running under Win8.1 or Win10 shows the TextBox with its vertical scrollbar centered vertically within a larger TextBox area.

It seems to be a WPF layout problem. The code was developed in VS2013, .net 4.5. All tested windows systems are x64. Any ideas to make this simple app running with same results in win7 ... win10?

Upvotes: 0

Views: 203

Answers (1)

Alireza
Alireza

Reputation: 5533

Remove the line

MaxLines="6" 

it is causing your Textbox to be limited in height and appear vertically centered in Window

Upvotes: 1

Related Questions