Designtime support when there is no App.xaml

Topics: Framework Services
Aug 2, 2012 at 9:56 AM
Edited Aug 2, 2012 at 9:57 AM

In my Bootrapper class I have some custom convetions for ViewLocation. Unfortunately the Views and ViewModels are in a DLL project, not a WPF EXE project, so I don't have a App.xaml that could create the bootrapper before Bind.AtDesignTime is set and before d:DataContext is applied for any give View (UserControl) in my DLL project.

How can I have designtime support (that my views are resoved correctly using my conventions) when the Views and the ViewModels are in a DLL?

Aug 14, 2012 at 2:02 PM

I ended up creating a custom attached property that I use instead of Bind.AtDesignTime that I use in each XAML view. It creates the Bootstrapper for me every time the designer is opened:

    internal static class Bind
        public static readonly DependencyProperty AtDesignTimeProperty =
                                                typeof (bool),
                                                typeof (Bind),
                                                new PropertyMetadata(false, OnAtDesignTimeChanged));

        public static bool GetAtDesignTime(DependencyObject element)
            return (bool)element.GetValue(AtDesignTimeProperty);

        public static void SetAtDesignTime(DependencyObject element, bool value)
            element.SetValue(AtDesignTimeProperty, value);

        private static void OnAtDesignTimeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
            if (!Execute.InDesignMode)

            new DesignTimeBootstrapper();
            Caliburn.Micro.Bind.SetAtDesignTime(sender, true);





Dec 13, 2012 at 11:06 AM
Edited Dec 13, 2012 at 11:06 AM

Arrrgh, I just upgraded to 1.4 and now the designtime support does not work anymore. The Views cannot be resolved anymore.

Dec 13, 2012 at 12:10 PM
Edited Dec 13, 2012 at 12:25 PM

It seems that in Caliburn Micro 1.4 I have to override SelecteAssemblies in my DesignTimeBootstrapper

using System.Collections.Generic;
using System.Reflection;
using Caliburn.Micro;
using Common;
internal class DesignTimeBootstrapper : Bootstrapper<IShell>
    protected override void Configure()

    // this method had to be overridden
    protected override IEnumerable<Assembly> SelectAssemblies()
        yield return typeof (DesignTimeBootstrapper).Assembly;

Now I will donate another 20€ to this project if someone can plausibly explain, why I have to do this now. Looking at the checkin hisory of this project, I can't find the root cause of this breaking change by myself. Why didn't I have to override SelectAssemblies in 1.3 (it could resolve the Views correctly at designtime) but now in 1.4 I have to.

Dec 15, 2012 at 9:19 AM
Edited Dec 15, 2012 at 9:20 AM

SelectAssemblies() in Caliburn.Micro 1.3.1:

        protected virtual IEnumerable<Assembly> SelectAssemblies() {
            if (Execute.InDesignMode) {
                var appDomain = AppDomain.CurrentDomain;
                var assemblies = appDomain.GetType().GetMethod("GetAssemblies")
                                     .Invoke(appDomain, null) as Assembly[] ?? new Assembly[] { };
                return new[] {
                        .Where(x => x.EntryPoint != null && x.GetTypes().Any(t => t.IsSubclassOf(typeof(Application))))
            return new[] { Application.Current.GetType().Assembly };
            return new[] { Assembly.GetEntryAssembly() };

Also in that version only the assembly containing the Application class was selected. So I can't figure out how it has worked for you.