Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial declarations of must not specify different base classes

Tags:

c#

wpf

I know there is information on this on the internet but Im having problems translating it to my situation.

I have a xaml window and im getting the error: Partial declarations of 'GX3OpenStackupGUIPlugin.GX3OpenStackupGUIPlugin' must not specify different base classes .

My code behind is:

public partial class GX3OpenStackupGUIPlugin : GX3ClientPlugin, IGX3PluginInterface
    {

My xaml is:

<Grid xmlns:my="clr-namespace:CustomControls;assembly=MultiComboBox"   xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"   x:Class="GX3OpenStackupGUIPlugin.GX3OpenStackupGUIPlugin"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

Please could someone advise :)

Here is a link to what I have found but am struggling to translate... Partial declarations must not specify different base classes

After doing a little more research I have discovered that if I change my code behind to implement the top level element in my xaml it gets rid of the error. Thats obviously still a problem as my codebehind class needs to implement the interfaces I have designed.

like image 223
user589195 Avatar asked May 02 '12 12:05

user589195


1 Answers

The question you linked to contains the answer. The person who asked that question started with this (which worked):

<A x:Class="B">
public partial class B : A

And they changed it to this (which didn't work):

<A x:Class="C">
public partial class C : B

This doesn't work because, behind the scenes, a .cs file is generated based on the XAML that contains a partial class that inherits from A. To fix it, they needed to change it to this:

<B x:Class="C">
public partial class C : B

So in your case, I believe you should replace Grid, i.e. do something like this:

<namespace:GX3ClientPlugin x:Class="namespace.GX3OpenStackupGUIPlugin">
public partial class GX3OpenStackupGUIPlugin : GX3ClientPlugin

(I assume that GX3ClientPlugin ultimately inherits from something like Grid or UserControl?)

like image 199
Andrew Avatar answered Sep 26 '22 20:09

Andrew