c# - VS Designer not working when adding a user control from another project -


i creating universal app in visual studio 2015. universal app has reference universal library called uicomponents.

in uicomponents created user control:

namespace myproj.uicomponents {   public sealed partial class mycontrol : usercontrol   {     public mycontrol()     {       this.initializecomponent();     }   } } 

with following xaml:

<usercontrol     x:class="myproj.uicomponents.mycontrol"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:local="using:myproj.uicomponents"     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     mc:ignorable="d"     d:designheight="300"     d:designwidth="400">      <grid>         <rectangle fill="white" horizontalalignment="left" height="280" stroke="black" verticalalignment="top" width="380" margin="10,10,0,0"/>         <textbox x:name="textbox" margin="20,20,20,20" textwrapping="wrap" text="textbox"/>      </grid> </usercontrol> 

inside app project, references uicomponents, this:

<page     x:class="myproj.app.mainpage"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:local="using:myproj.app"     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     xmlns:ui="using:myproj.uicomponents"     mc:ignorable="d">      <grid background="{themeresource applicationpagebackgroundthemebrush}">         <ui:mycontrol></ui:mycontrol>     </grid> </page> 

but when try designer display page get:

enter image description here

the error list shows this:

the name "mycontrol" not exist in namespace "using:myproj.uicomponents".

funny thing whole solution builds fine, designer not collaborating.

attempt using clr-namespace

there similar questions in wpf, not strictly universal apps, , marked solved on answers solution use:

xmlns:ui="clr-namespace:myproj.uicomponents"  

bu not work:

undefined clr namespace. 'clr-namespace' uri refers namespace 'myproj.uicomponents' not found.

the error list shows this:

the name "mycontrol" not exist in namespace "using:myproj.uicomponents".

in experience, caused

  1. the uicomponents library didn't got built.

    after building library project, vs add following codes yourproject.proj file, detected vs designer:

    <itemgroup>//the following lines added.    <page include="mycontrol.xaml">    <generator>msbuild:compile</generator>       <subtype>designer</subtype>    </page> </itemgroup> 

    so, please try building library project , rereference in main project.after reloading, designer should load contents correctly.

    notes: architecture(x64,x86) when building library should identical current architecture. (e.g. when build library x86. designer can't load correctly, when current architure x64).

  2. the namespace wrong, seems not main cause here.


Comments