wpf - WPF Visual Studio:主窗口无法缩放以适应 Windows 屏幕
问题描述
重新安装 Visual Studio 后,任何 WPF 项目中的主窗口都不再缩放为 Windows 中选择的比例。我已将屏幕的比例设置为 125%,并且在窗口和其中的所有文本都增大之前。现在,它是与 100% 比例保持相同大小的主窗口。如何解决?
除了重新安装之外,我唯一做的就是根据此处的说明设置值:url
setx VSXAML_DISABLE_ON_DEMAND_RESOURCE_VALUES 1
例子:
接口规模 125%
主窗口和对话窗口
两个窗户的尺寸 -Height="450" Width="800"
缩放150%
我提醒你,窗户的大小是一样的。
我能做些什么呢?
主窗口:
<Window x:Class="TestWpfApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TestWpfApp"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800"
Background="DarkGray">
<Grid Background="#222222">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Button x:Name="btn" Grid.Row="1" Content="Button"/>
</Grid>
</Window>
对话:
<Window x:Class="TestWpfApp.Dialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TestWpfApp"
mc:Ignorable="d"
Title="Dialog" Height="450" Width="800" Opacity="0.5">
<Grid>
<TextBlock Text="Test Text" FontSize="25"/>
</Grid>
</Window>
解决方案
推荐阅读
- php - 使用 laravel 上传多个文件
- css - 如何忽略容器的宽度,向右溢出,而不破坏页面?
- python - 屏幕上的 Python Turtle 中心龟
- regex - 正则表达式排除带有点和 0 位的数字
- javascript - 这些异步方法声明之间有什么区别?
- reactjs - 使用 React CDN 时如何使用 material-ui 的 Autocomplete 组件
- kubernetes - 带有边车日志容器的 Cronjob 没有退出代码
- sybase - 使用 BCP 将数据导入 sybase 表失败并出现溢出错误
- c# - 多次导入同一个DLL库,动态DllImport注解
- python - 如何从列表中选择多个元素?