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; ">}