Caliburn.Micro 是否支持设计时数据?我尝试了以下步骤;我创建了一个简单的 hello world 程序。ShellViewModel 是从 IShell 派生的。通过运行示例程序,它会在运行时显示 hello word。由于视图模型是从 IShell 派生的,我创建了一个同样从 IShell 派生的虚拟类,并将其用作设计时实例。
public class SampleShellViewModel:IShell
{
#region IShell Members
public string HelloWorld
{
get { return "Hello World"; }
}
#endregion
}
在视图中,我添加了设计时上下文,如下所示
<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>
有什么我想念的吗?谢谢