Bizzare problem that I found while working with Caliburn micro’s window manager.
I have the following code which shows a dialog window
sendLogicDialogViewModel.Initialize(CompiledCodeList);
dynamic settings = new System.Dynamic.ExpandoObject();
settings.WindowStartupLocation = WindowStartupLocation.CenterScreen;
windowManager.ShowDialog(sendLogicDialogViewModel, null, settings);
Which works perfectly.. but for some reason it’s screwing around with the view’s declaration of window height in XAML. I’ve made a very simple view to demonstrate my point:
<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>
This is what I expect to see in the dialog window (This is what it shows in design view of Visual Studio)

But instead, this is what I get:

What gives? Why is it setting the height/width of the dialog window arbitrarily? Is there some setting that I have to touch in windowManager? How can I solve this issue?
You can add
SizeToContent="WidthAndHeight” to your rootWindowelement in yourSendLogicDialogView, or pass it as another setting.This behaviour isn’t specific to Caliburn.Micro, it is the standard WPF behaviour when a
WidthandHeightaren’t specified on theWindowand theSizeToContentis set toManual(the default), the window will have a default width and height.