Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial declarations, must not specify different base classes

Tags:

c#

wpf

xaml

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?

Base class:

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

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

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"

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

Partial declarations of 'ProgramManagementV2.screens.MainUserControl' must not specify different base classes

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

like image 955
NomenNescio Avatar asked Aug 20 '12 14:08

NomenNescio


1 Answers

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

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

like image 95
H.B. Avatar answered Sep 18 '22 19:09

H.B.