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?
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
{
//...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With