我目前正在制作一个 wpf 应用程序,并希望在某些操作期间禁用窗口大小调整。我一直在使用this.ResizeMode = System.Windows.ResizeMode.CanMinimize;
,这正是我想要的,但它使窗口比以前更大。
我不知道这是否可能,但有没有办法避免窗口扩大?
编辑:
这是一个非常简单的 wpf 应用程序来演示这个问题。
xml:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Content="Trigger CanMinimize" Height="23" HorizontalAlignment="Left" Margin="62,248,0,0" Name="canMin" VerticalAlignment="Top" Width="120" Click="canMin_Click" />
<Button Content="Trigger CanResize" Height="23" HorizontalAlignment="Left" Margin="327,248,0,0" Name="canRes" VerticalAlignment="Top" Width="108" Click="canRes_Click" />
</Grid>
</Window>
cs 文件:
using System.Windows;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void canMin_Click(object sender, RoutedEventArgs e)
{
this.ResizeMode = System.Windows.ResizeMode.CanMinimize;
}
private void canRes_Click(object sender, RoutedEventArgs e)
{
this.ResizeMode = System.Windows.ResizeMode.CanResize;
}
}
}