分部声明一定不能指定不同的基类 [英] Partial declarations of must not specify different base classes

查看:4319
本文介绍了分部声明一定不能指定不同的基类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有这个信息在互联网上,但有问题将其转换成我的处境林。

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

我有一个XAML窗口,并即时得到错误:GX3OpenStackupGUIPlugin.GX3OpenStackupGUIPlugin的分部声明一定不能指定不同的基类

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

我后面的代码为:

public partial class GX3OpenStackupGUIPlugin : GX3ClientPlugin, IGX3PluginInterface
    {

我的XAML是:

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

请会有人提醒:)

这里是什么我已经找到,但我努力翻译...
分部声明一定不能指定不同的基类

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

做一点更多的研究,我发现后,如果我的背后更改我的代码来实现在我的XAML中顶级元素它摆脱了错误的。那显然还是一个问题,因为我隐藏类需要实现我所设计的接口。

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.

推荐答案

您链接到的问题中包含了答案。谁问这个问题的人开始使用此(这工作):

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

这不起作用,因为,幕后,一个cs文件是基于包含从A继承要修复它的部分类XAML产生的,他们需要把它改成这样:

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



(我假设GX3ClientPlugin最终从类似网格继承或用户控件?)

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

这篇关于分部声明一定不能指定不同的基类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆