Design-time support

Topics: Getting Started
Jul 16, 2012 at 1:08 PM
Edited Jul 16, 2012 at 1:08 PM


I'm new to Caliburn.Micro and wanted to ask on the desin-time support of it.
There are several blogs and MVVM framework comparisons saying that Caliburn.Micro does not support Expression Blend and the Visual Studio designer.

This was the only blog entry I found, stating that design-time is suported by Caliburn.Micro:

Are there any docs/blog posts stating what is working on design time and what you should  not use if you work with Blend?

Jul 20, 2012 at 5:50 PM
Edited Jul 20, 2012 at 5:53 PM

OK, i got the design-time support working...

d:DataContext="{d:DesignInstance local:ShellViewModel, IsDesignTimeCreatable=True}" cal:Bind.AtDesignTime="True"

The binding conventions seem to work in Visual Studio and Blend, but the action conventions NOT.

On ICommand bindings the CanExecute method is evaluated at design-time.
It would be great if the “CanExecute” guard is evaluated at design-time too.

Is this possible???

Jul 20, 2012 at 6:55 PM

I'm not sure if it's possible. The design-time support we have is pushing the system pretty far already. Unfortunately, I have never been able to get the Blend team to discuss this need with me. They've rejected even having a conversation with me on improving anything related to design-time support. I would contact the Blend team and/or people who are in leadership positions over them and voice your concern and tell them how important this framework is to your development.

Jul 20, 2012 at 7:15 PM

Thanks for the fast response.

Sep 7, 2012 at 12:04 AM
Edited Sep 7, 2012 at 12:08 AM

I'm new to Caliburn.Micro and I'm developing on WP7.1 trying to figure out how to use sample data at design time.

I tried two different way:

1) Using DesignInstance:


<UserControl x:Class="RawTraining.ViewModels.BlogListView"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480"    
    d:DataContext="{d:DesignInstance local:BlogListViewModel, IsDesignTimeCreatable=True}"

<Grid x:Name="LayoutRoot">
        <TextBlock x:Name="Title"/>

and in the ViewModel:
public class BlogListViewModel : Screen
        public string Title { get; set; }

        public BlogListViewModel()
            if (Execute.InDesignMode)

        private void LoadDesignData()
            Title = "MMMMMMMmmmmmm.....";

2) Using DesignData:
d:DataContext="{d:DesignData /SampleData/BlogListViewModelSampleData1.xaml}"

 <Grid x:Name="LayoutRoot" >
        <TextBlock x:Name="Title"/>

Both method give no result, only the second one works changing the TextBlock to get the property with traditional "{Binding Title}", but in this way I'm not using Caliburn bindings. Please is there anyone that could give me some tips or suggest me a wp7 example that uses designTime data?
Thanks in advance, best regards Roberto

Nov 20, 2012 at 6:54 PM

I've managed to get Caliburn Micro to work nicely with Blend at design-time, using d:DesignInstance, by modifying the bootstrapper as follow:

        /// <summary>
        /// Overriding only to avoid a design-time error (see below)
        /// </summary>
        /// <returns></returns>
        protected override IEnumerable<Assembly> SelectAssemblies()
            if (Execute.InDesignMode)
                var appDomain = AppDomain.CurrentDomain;
                var assemblies = appDomain.GetType()
                                     .Invoke(appDomain, null) as Assembly[] ?? new Assembly[] {};

                // the following original line raises an exception at design time so I've commented it and substituted for the lines that follow
                // var applicationAssembly = assemblies.LastOrDefault(x => !x.IsDynamic && x.GetExportedTypes().Any(t => t.IsSubclassOf(typeof(Application))));
                var applicationAssemblies = new List<Assembly>();
                foreach (var assembly in assemblies)
                        if (!assembly.IsDynamic && assembly.GetExportedTypes().Any(t => t.IsSubclassOf(typeof (Application))))
                    catch (Exception)
                return applicationAssemblies;

            return new[] {Application.Current.GetType().Assembly};

        /// <summary>
        /// Overriding to allow design-time ViewModel resolution
        /// </summary>
        protected override void StartDesignTime()

            var actual = ViewModelBinder.Bind;
            ViewModelBinder.Bind = (viewModel, view, context) =>
                    var vmType = viewModel.GetType();
                    // when using d:DesignInstance, Blend tries to assign the DesignInstanceExtension class as the DataContext, so here we
                    // get the actual ViewModel which is in the Instance property of DesignInstanceExtension
                    if (vmType.FullName == "Microsoft.Expression.DesignModel.InstanceBuilders.DesignInstanceExtension")
                        var propInfo = vmType.GetProperty("Instance", BindingFlags.Instance | BindingFlags.NonPublic);
                        viewModel = propInfo.GetValue(viewModel, null);
                    actual(viewModel, view, context);

 Hope this helps anyone with design-time issues.

Nov 20, 2012 at 7:36 PM

If you feel this code is generic enough to push into the core framework to improve the design-time experience, then please feel free to submit a pull request. We are switching over to git on Codeplex in a few days. So, you might need to wait until then. Thanks!

Dec 8, 2012 at 7:04 PM

Hi samirzattar,

I have applied your changes now. May you review them, please.