Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial declarations, must not specify different base classes?

Tags:

wpf

xaml

When I changed this:

public partial class FrmCategories : UserControl

to this:

public partial class FrmCategories : MyUserControl

Where MyUserControl inherits from UserControl.

I got this error:

Error 2 Partial declarations of 'WpfTest.FrmCategories' must not specify different base classes

\Projects\WpfTest\WpfTest\FrmCategories.xaml.cs 21 26 WpfTest

XAML:

<UserControl x:Class="WpfTest.FrmCategories"
             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:we="clr-namespace:WpfTest"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" Background="Azure" Height="131" Width="229">
    <StackPanel Margin="5,24,5,0" Name="catFrm" Height="75" VerticalAlignment="Top">

I'm beginning WPF (as the name of the project implies), so I expect a trivial error here

like image 602
mshwf Avatar asked Aug 31 '25 22:08

mshwf


1 Answers

You need to change the root element of the XAML file:

<we:MyUserControl x:Class="WpfTest.FrmCategories"
             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:we="clr-namespace:WpfTest"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" Background="Azure" Height="131" Width="229">
    <StackPanel Margin="5,24,5,0" Name="catFrm" Height="75" VerticalAlignment="Top">
</we:MyUserControl>
like image 99
mm8 Avatar answered Sep 03 '25 10:09

mm8