today i'm facing problem "solved" days ago. first facts: visual studio 2013 desginerview
i've got custom usercontrol inherited usercontrol first. time later needed base-class between customcontrol , usercontrol spread virtual functions on controls (all controls should inherit "basecontrol").
so classes like:
public class customcontrol : basecontrol { } public class basecontrol : usercontrol { public virtual bool finished() { return false; } }
now if try open customcontrol visual studio designer following error: visual studio cannot open designer file because class within not inherit class can visually designed
some days ago problem occurs under debug-configuration, , fixed after hours using [designtimevisible(false)]
-attribute @ basecontrol.
but after moving files project in solution i've got errror again.
winforms usercontrol:
modify code generated designer in customcontrol.designer.cs
file:
partial class customcontrol:basecontrol { ... }
also, there should .designer.cs
file basecontrol
, otherwise won't work.
the codebehind basecontrol
:
public partial class basecontrol : usercontrol { public basecontrol() { // code generated automatically initializecomponent(); } public virtual bool finished() { return false; }
}
wpf usercontrol:
the code basecontrol
should located in plain basecontrol.cs
file. there shouldn't .xaml
or .xaml.cs
files basecontrol
(this important)
namespace mynamespace { public class basecontrol:usercontrol { //... } }
in .xaml.cs
file of customcontrol
, there should be:
namespace mynamespace { public partial class customcontrol: basecontrol { //.... } }
in .xaml
file of customcontrol
:
<local:basecontrol x:class="mynamespace.customcontrol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:mynamespace"> <grid> </grid> </local:basecontrol>
and not:
<usercontrol x:class="mynamespace.customcontrol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <grid> </grid> </usercontrol>