次のように d:DataContext にバインドされた設計時のビュー モデルがいくつかあります。
<UserControl x:Class="MyProject.Views.CallRecordView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:MyProject.ViewModels.DesignTime"
d:DataContext="{d:DesignInstance Type=vm:MyDesignViewModel, IsDesignTimeCreatable=True}"
mc:Ignorable="d vm">
からまでBuild Action
のすべてを変更しましたViewModel
Compile
DesignDataWithDesignTimeCreatableTypes
設計時に動作していますが、コンパイルしようとすると次のエラーが発生します。
Error 20519 The type or namespace name 'DesignTime' does not exist in the namespace 'MyProject.ViewModels' (are you missing an assembly reference?) ...\obj\Debug\Views\MyView.g.cs 13 35 MyProject
サンプル データがアセンブリに添付されないようにするにはどうすればよいですか? それとも、これは必要ではなく、コンパイラーは、Compile
設定してもデフォルトでこれらのファイルを実行可能ファイルに含めませんか?
// 編集:
DesignTime
また、空のクラスを名前空間に作成すると、すべてが機能し、コンパイルされます。
namespace MyProject.ViewModels.DesignTime {}
しかし、名前空間を変更したり、コンパイル時に空の名前空間を提供したりせずにそれを行うことはできますか?