C# MinWidth、MaxWidth、MinHeight、MaxHeight don';不影响<;用户控制>;

C# MinWidth、MaxWidth、MinHeight、MaxHeight don';不影响<;用户控制>;,c#,wpf,xaml,user-controls,caliburn.micro,C#,Wpf,Xaml,User Controls,Caliburn.micro,我正在学习使用Caliburn Micro framework创建WPF应用程序 按照主页上的教程:,我删除了默认生成的xaml,取而代之的是xaml,并通过我的AppBoostrapper引导它 以下是MainView.xaml: <UserControl x:Class="SmartRenamer.Views.MainView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

我正在学习使用Caliburn Micro framework创建WPF应用程序

按照主页上的教程:,我删除了默认生成的
xaml,取而代之的是
xaml,并通过我的
AppBoostrapper
引导它

以下是MainView.xaml:

<UserControl x:Class="SmartRenamer.Views.MainView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             MinHeight="300"
             MinWidth="300"
             MaxHeight="500"
             MaxWidth="1000">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Menu IsMainMenu="True" Grid.Row="0">
            <MenuItem Header="_File">
                <MenuItem Header="_Open Folder..." x:Name="OpenFolder"></MenuItem>
            </MenuItem>
            <MenuItem Header="_About" />
        </Menu>
        <ScrollViewer HorizontalScrollBarVisibility="Visible" Grid.Row="1" MaxHeight="500" MaxWidth="1000">
            <StackPanel>
                <DataGrid x:Name="FilesList">

                </DataGrid>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</UserControl>

问题是我想为我的应用程序设置
MinWidth、MaxWidth、MinHeight、MaxHeight
,但是
main窗口中的那些配置似乎不起作用。

以下是两个屏幕截图,其中窗口仍然可以在定义的范围外重新调整大小:


这里我错了什么?

UserControl的宽度和高度属性由保存该控件的容器设置。即,设计时使用的设计宽度和设计高度在UserControl中设置,但在运行时使用容器设置的值

我在Caliburn Micro方面没有经验,但您似乎可以在引导程序中定义设计属性:

   var settings = new Dictionary<string, object>
   {
       { "Height" , 300},
       { "Width"  , 300},
   };

   DisplayRootViewFor<ViewModel>(settings);
var设置=新字典
{
{“高度”,300},
{“宽度”,300},
};
DisplayRootViewFor(设置);

嘿!我现在有完全相同的问题,你现在知道如何解决吗?没有:(.我找不到解决方案。我已经解决了这个问题,但我的代码有问题。我们处理了WinAPI事件(WindowProc)-在这种情况下,我们的窗口甚至不使用MinWidth和MaxWidth;)