Friday, June 22, 2007

Visual Inheritance is Currently Disabled

Although CF2 has been released now since 07 November 2005, I'd thought I'd blog about this "issue" I received some time ago. As you are probebly aware, CF2 supports the UserControl class so design time support is much easier than it used to be in CF1. However, you might still get an error message after adding your new custom control to a form: "Visual Inheritance is Currently Disabled".

You might typically get this when the control uses P/Invokes or device level funtionality not supported on the desktop - such as the WindowsCE assembly.

There are two ways to get around this problem:-

1. Add an .Xmta (Design Time Attributes) file to your project.
2. Add the DesktopCompatible(true) attribute to the user control.

The prefered method is to add an .xmta (Design Time Attributes) file to your assembly. This is because typically if you have a library of controls you won't need to keep using the DesktopCompatible attribute for every form that uses your control. In addition you can add comments for memebers that will show up in the designer when using an .xmta file. The xml schema should be as follows:

<?xml version="1.0" encoding="utf-16"?>
<Classes xmlns="">
<Class Name="Company.Mobile.Forms.PropertyHeader">
<Property Name="Description">
<Description>Displays the description of the parent forms function.</Description>

The above example would be used in a case where your user control's class was named: Company.Mobile.Forms.PropertyHeader.


Anonymous said...

Thanks for the tip ;)

Gus said...

Thanks, solved a problem that just popped up