1

Caliburn.Microは設計時データをサポートしていますか?次の手順で試してみました。簡単なHelloWorldプログラムを作成しました。ShellViewModelはIShellから派生しています。サンプルプログラムを実行すると、実行時にhelloワードが表示されます。ビューモデルは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>

足りないものはありますか?ありがとう

4

3 に答える 3

4

Caliburn Microの設計データの例をご覧ください。デレク・ビーティ著。

于 2012-03-24T22:34:53.210 に答える
2

Bind.AtDesignTime を適用するとうまくいくはずです。

<UserControl 
     xmlns:cal="http://www.caliburnproject.org"
     cal:Bind.AtDesignTime="True"
     >
    <!-- etc -->
</UserControl>
于 2013-12-15T09:59:42.407 に答える