Inherit custom classes. Declarations must not specify different base classes

Source: Internet
Author: User

Different base classes cannot be specified.

The preceding exception specifies two different base classes for a custom class (C # only supports class-single inheritance). You can reference a custom class as follows:

<CC: customusercontrol X: class = "wpfapplication1.instanceusercontrol"

Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"

Xmlns: CC = "CLR-namespace: wpfapplication1"

Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"

Title = "customusercontroldemo" Height = "300" width = "300">

<Grid>

<Button content = "this is a custom window" margin = "5"/>

</GRID>

</CC: customusercontrol>

Public partial class instanceusercontrol: customusercontrol

{

Public instanceusercontrol ()

{

Initializecomponent ();

}

}
You can use mysurface instead of customusercontrol.

========================================================== ========================================================== ====

Example:

Window1.xaml
<CC: class1 X: class = "wpfapplication1.window1"
Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Xmlns: CC = "CLR-namespace: wpfapplication1"
Title = "window1" Height = "300" width = "300">
<Grid>

</GRID>
</CC: class1>

Window1.xaml. CS

Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Using system. windows;
Using system. Windows. controls;
Using system. Windows. Data;
Using system. Windows. documents;
Using system. Windows. input;
Using system. Windows. Media;
Using system. Windows. Media. imaging;
Using system. Windows. Navigation;
Using system. Windows. shapes;

namespace wpfapplication1
{< BR style = "line-Height: normal; ">///


// interaction logic of window1.xaml
///
Public partial class window1
{< BR style =" line-Height: normal; "> Public window1 ()
{< BR style =" line-Height: normal; "> initializecomponent ();
}

Protected override void Hello ()
{
MessageBox. Show ("Hell world! ");
}
}
}

Class1.cs

Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;

Using system. windows;

namespace wpfapplication1
{< BR style = "line-Height: normal; "> public class class1: Window
{< BR style =" line-Height: normal; "> Public class1 ()
{< BR style = "line-Height: normal;"> Hello ();
}

protected virtual void Hello ()
{< BR style =" line-Height: normal; "> MessageBox. show ("hello");
}< BR style = "line-Height: normal; ">}< BR style =" line-Height: normal; ">}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.