Search code examples
silverlight-4.0caliburn.microdesign-time-data

Does Caliburn.Micro support design time data?


Does Caliburn.Micro support design time data? I tried out with following steps; I created a simple hello world program. Where ShellViewModel is derived off of IShell. By running the sample program it does show hello word at run time. Since the view model is derived off of IShell I created a dummy class also derived off of IShell and used it as the design time instance.

public class SampleShellViewModel:IShell
{

    #region IShell Members

    public string HelloWorld
    {
        get { return "Hello World"; }
    }

    #endregion
}

in the view I added the design time context as follows

<UserControl x:Class="HelloWorld.ShellView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         mc:Ignorable="d"
         xmlns:sampleData="clr-namespace:HelloWorld"
         d:DesignHeight="287" d:DesignWidth="518"
         >

<Grid Background="White" d:DataContext="{d:DesignInstance sampleData:SampleShellViewModel, IsDesignTimeCreatable=True}">
    <TextBlock Name="HelloWorld"
               VerticalAlignment="Center"
               HorizontalAlignment="Center"
               FontSize="20" />
</Grid>

Is there anything I a missing? Thanks


Solution

  • Quoting Graeme's comment, since it answered my question.

    Okay your d:DataContext="blah... code is perfect you still need Text={Binding HelloWorld} for blend to access the data (Id completely glossed over looking at that part), Blend doesn't run the xaml through the Caliburn convention binder. It needs to be explicitly set.

    – Graeme Bradbury Jul 22 at 15:14"