以下代码与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 test test test test test test test test "/>
</Grid>
在Win8.1或Win10下运行的相同代码显示TextBox,其垂直滚动条在较大的TextBox区域内垂直居中。
这似乎是一个WPF布局问题。该代码是在VS2013,.net 4.5中开发的。所有经过测试的Windows系统都是x64。 任何使这个简单的应用程序以相同的结果运行的想法都会在win7 ... win10?
答案 0 :(得分:1)
删除行
MaxLines="6"
导致Textbox
的身高受到限制,并在Window