gpt4 book ai didi

c# - Caliburn Micro 对话框窗口的宽度/高度被任意设置

转载 作者:行者123 更新时间:2023-11-30 21:02:30 24 4
gpt4 key购买 nike

我在使用 Caliburn micro 的窗口管理器时发现的奇怪问题。

我有以下显示对话窗口的代码

sendLogicDialogViewModel.Initialize(CompiledCodeList);
dynamic settings = new System.Dynamic.ExpandoObject();
settings.WindowStartupLocation = WindowStartupLocation.CenterScreen;

windowManager.ShowDialog(sendLogicDialogViewModel, null, settings);

这完美地工作..但出于某种原因,它在 XAML 中对窗口高度的 View 声明进行了修改。我做了一个非常简单的观点来证明我的观点:

<Window x:Class="DDCLogicInstaller.SendLogicDialogView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="{Binding Title}"
xmlns:cal="http://www.caliburnproject.org"
cal:Bind.Model="DDCLogicInstaller.SendLogicDialogViewModel"
>
<Button Content="300" Height="100" Width="100"/>
</Window>

这是我希望在对话框窗口中看到的内容(这是它在 Visual Studio 的设计 View 中显示的内容)

enter image description here

但是,这就是我得到的:

enter image description here

什么给了?为什么要任意设置对话框窗口的高度/宽度?在 windowManager 中是否有一些我必须触摸的设置?我该如何解决这个问题?

最佳答案

您可以将 SizeToContent="WidthAndHeight"添加到您的 SendLogicDialogView 中的根 Window 元素,或将其作为另一个设置传递。

此行为并非特定于 Caliburn.Micro,当 Window< 上未指定 WidthHeight 时,它是标准 WPF 行为 并且 SizeToContent 设置为 Manual(默认值),窗口将具有默认宽度和高度。

关于c# - Caliburn Micro 对话框窗口的宽度/高度被任意设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13476124/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com