Reputation: 7030
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?
Upvotes: 2
Views: 2418
Reputation: 34349
You can add SizeToContent="WidthAndHeight
" to your root Window
element in your SendLogicDialogView
, or pass it as another setting.
This behaviour isn't specific to Caliburn.Micro, it is the standard WPF behaviour when a Width
and Height
aren't specified on the Window
and the SizeToContent
is set to Manual
(the default), the window will have a default width and height.
Upvotes: 5