views:

474

answers:

1

I'm having problems displaying custom (inherited) controls in my .NETCF windows mobile project in Visual Studio. The control appears on the designer surface as a gray box with the class name written in it.

As a test case I have a simple control defined as:

public class ucButton2 : Button
{
}

Should be just like a button but it gives the funny behavior.

In the past I've solved this problem or similar problems with a Design Time Attributes file. So I included the file DTA.xmta with the following contents

<?xml version="1.0" encoding="utf-16"?>
<Classes xmlns="http://schemas.microsoft.com/VisualStudio/2004/03/SmartDevices/XMTA.xsd"&gt;
  <Class Name="MyProject.CustomControls.ucButton2">
    <Description>Testbutton</Description>
    <DesktopCompatible>true</DesktopCompatible>
  </Class>
</Classes>

Now things get truly bizarre -- I start getting compile errors from genasm.exe in unrelated Typed Data Set files.

Following advice from the last comment on this post: http://www.simonrhart.com/2008/02/upgrading-your-solutions-to-visual.html

I changed DTA.xmta to have a build action of "Embedded Resource"

Now the app compiles, but nothing has changed -- the designer surface still shows just an empty box with the class name.

I've closed and re-opened Visual Studio to ensure there's no weird caching happening -- same behavior.

Like I said, in the past the xmta file has solved this kind of problem. But it didn't this time. But at the same time, in the past, adding an xmta file didn't cause genasm.exe to barf at compile time. In my other project my xmta file has a build action of 'none', not 'embedded resource'.

At run time, everything works fine. This is purely a design time problem. Any help would be much appreciated.

A: 

This is because the smart device control designer does not support visual inheritance -- or should I say it doesn't display it richly. Whether by code defect or by design, it doesn't work like desktop .NET control designer. Sometimes it will display it, sometimes it won't.

But your custom control code will still work, it just doesn't always display as expected.

David G