Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging how Caliburn.micro places your usercontrol on a window
    text
    copied!<p>I have an app using Caliburn.micro and a custom window manager. The window manager is creating my own Base Window so I can customize the look and feel across the application. </p> <p>I would like to add some controls on the window something like:</p> <pre><code>&lt;DockPanel&gt; &lt;ContentPresenter Content="{Binding CustomContent}" /&gt; &lt;StatusBar Height="20" DockPanel.Dock="Bottom" Background="Blue"/&gt; &lt;/DockPanel&gt; </code></pre> <p>I would like to have Caliburn put the usercontrol from my ViewModel in the ContentPresenter, but Caliburn is replacing the entire content of my window. </p> <p>I did this in the window:</p> <pre><code>using System.Windows; namespace CaliburnCustomWindow { public partial class WindowBase { public static readonly DependencyProperty CustomContentProperty = DependencyProperty.Register("CustomContent", typeof (object), typeof (WindowBase)); public object CustomContent { get { return GetValue(CustomContentProperty); } set { SetValue(CustomContentProperty, value); } } public WindowBase() { InitializeComponent(); } } } </code></pre> <p>And then modified my WindowManager to do this:</p> <pre><code>using System.Windows; using Caliburn.Micro; namespace CaliburnCustomWindow { internal class AppWindowManager : WindowManager { protected override Window EnsureWindow(object model, object view, bool isDialog) { Window window = view as Window; if (window == null) { if (view.GetType() == typeof (MainView)) { window = new WindowBase { CustomContent = view, SizeToContent = SizeToContent.Manual }; window.Height = 500; window.Width = 500; } window.SetValue(View.IsGeneratedProperty, true); } else { Window owner2 = InferOwnerOf(window); if (owner2 != null &amp;&amp; isDialog) { window.Owner = owner2; } } return window; } } } </code></pre> <p>But it doesn't work. That binding to the CustomContent dependency property doesn't seem to work. </p> <p>Is is possible to do this? If so how?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload