4

I am making a unit converter for windows phone but I'm having some problems with class inheritance.

I have the class Measurement which is supposed to be the top class for the graphical content in my program.

public class Measurement : PhoneApplicationPage
{
    public void Convert(object give)
    {
        supervar.Comparer(this);
    }
    public WindowsPhoneControinput supervar { get; set; }
}

Measurement does not contain any graphical content, but it's subclasses do; And here is where I am having difficulties.

The subclasses: Lengthco, Weigthco and Volumeco needs to inherit from Measurement but the compiler says:

"Partial declarations declarations of 'Phoneapp1.Lengthco' Must not specify different base classes".

Why is this happening?

Scott
  • 21,211
  • 8
  • 65
  • 72
Jakob Danielsson
  • 767
  • 1
  • 8
  • 16

1 Answers1

7

That happens because the XAML-code inherits from another class:

<UserControl x:Class="myNamespace.MyControl">
    ....
</UserControl>

results in

public partial class MyControl : UserControl
{
    //...
}

If you want to inherit the control from another base class, you must use that in XAML, too:

<Measurement x:Class="myNamespace.MyControl">
    ....
</Measurement>
public partial class MyControl : Measurement 
{
    //...
}
Spontifixus
  • 6,570
  • 9
  • 45
  • 63