2

I have some Design time view models bound to d:DataContext like this:

<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">

I changed Build Action of every ViewModel from Compile to DesignDataWithDesignTimeCreatableTypes

and it's working on design time, but when I try to compile I get following errors:

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

how can I prevent my sample data from being attached to an assembly? Or maybe this is not neccessary and the compiler wouldn't include those files into executable by default even on Compile setting?

// edit:

also - everything is working and compiling when I create an empty class into DesignTime namespace:

namespace MyProject.ViewModels.DesignTime {}

but can I do it without changing my namespace or providing an empty one for compile time?

Adassko
  • 5,201
  • 20
  • 37

0 Answers0