Windows 8.1和Windows 10的文本框行为奇怪
本文关键字:Windows 文本 | 更新日期: 2023-09-27 18:10:10
下面的代码在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下运行的相同代码显示文本框的垂直滚动条在更大的文本框区域中垂直居中。
这似乎是一个WPF布局问题。代码是在VS2013, .net 4.5中开发的。所有测试的windows系统都是x64。有什么想法让这个简单的应用程序在win7中运行相同的结果…win10吗?
删除
MaxLines="6"
它会导致你的Textbox
在高度上受到限制,并在Window
中出现垂直居中