Partial declarations shouldn't specify different base classes?
I see many other people asking about this error message in other questions, but I don't seem to understand enough what's going on to fix it for myself. I created this error using WPF UserControl
public partial class EnterNewRequest : UserControl
But then I wanted to add a method to the UserControl, so I used inheritance to insert it there (don't use an extension because I need to override this method). But now my user control is frustrated and I'm not sure what in the xaml I need to change. The UserControl change block is located in the RCO_Manager namespace. This is my xaml:
<UserControl x:Class="RCO_Manager.EnterNewRequest"
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"
source to share
I had the same problem when I was working with Windows Phone. I can't remember the exact exception, but you can see the XAML here on GitHub , the page code here, and the base page code here (mine was the base page, not the base control). I needed to add a new namespace XAML
and change the declaration <UserControl/>
:
Supposed code
namespace RCO_Manager
{
// Inherits **Base**UserControl, not UserControl
public partial class EnterNewRequest : BaseUserControl
{
// Magic goes here
...
}
}
XAML
<local:BaseUserControl
xmlns:local="clr-namespace:RCO_Manager"
x:Class="RCO_Manager.EnterNewRequest"
Side note
According to Baboon, you don't need to specify it in your code after you specify the base class in XAML
, so you can then modify the code to show the following. I can't test it right now, but you can give it a try after you get it working.
public partial class EnterNewRequest // Don't specify BaseUserControl here
{
...
source to share