不得指定不同的基类

不得指定不同的基类

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

问题描述

我知道有这个互联网上的信息,我已经寻找它。 ?但我仍然得到错误,任何人都可以指出我什么我做错了。

I know there is information about this on the internet and I've searched for it. But I'm still getting the error, can anyone point out to me what I'm doing wrong?

的基类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace ProgramManagementV2.screens
{
    public abstract class AScreenUserControl : UserControl
    {
        public string GetScreenDescriptionName()
        {
            return "No name yet!";
        }
    }
}



MainUserControl.xaml

MainUserControl.xaml

<UserControl x:Class="ProgramManagementV2.screens.MainUserControl"
             xmlns:we="clr-namespace:ProgramManagementV2.screens"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <TextBlock Height="23" HorizontalAlignment="Center" Name="textBlock1" Text="asdfasdf" VerticalAlignment="Center" />
    </Grid>
</UserControl>



MainUserControl.xaml.cs:

MainUserControl.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;
using System.ComponentModel;

namespace ProgramManagementV2.screens
{
    /// <summary>
    /// Interaction logic for MainUserControl.xaml
    /// </summary>
    public partial class MainUserControl : AScreenUserControl
    {
        public MainUserControl()
        {
            InitializeComponent();
        }
    }
}



正如你可以看到我'米中加入

As you can see I'm adding

xmlns:we="clr-namespace:ProgramManagementV2.screens"

用户控制的XML,但我仍然得到错误:

to the user control xml but I'm still getting the error:

ProgramManagementV2.screens.MainUserControl的分部声明一定不能指定不同的基类

任何人都可以向我解释什么,我?在做错误的。

Can anyone explain to me what I'm doing wrong?

推荐答案

通过使用<用户控件... 你声称基类是用户控件,你需要将其更改为

By using <UserControl ... you claim the base-class to be UserControl, you would need to change it to

<we:AScreenUserControl x:Class="ProgramManagementV2.screens.MainUserControl" ...

用户控件只允许继承一个级别,我认为,至少如果 AScreenUserControl 有一个XAML这肯定不管用。

However UserControls only allow one level of inheritance i think, at least if the AScreenUserControl has a XAML this surely will not work.

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

08-13 19:48