Hi, Little to go on here, but this usually happens when the code behind and the xaml file do not inherit from the same base class.
Since we do not have all the details concerning your problem, I'll create a situation that will cause the same exception to be thrown, this might help you understand your problem.
As an example, just create new WPF application using Visual Studio, The XAML might look something like this:
<Window x:Class="WpfApplication1.MainWindow" .....>
The code behind would then contain something like this:
public partial class MainWindow : Window
{
//Code here
}
Note the 'partial' modifier here. It means this class (MainWindow) might not be defined in a single file but spread out across multiple files, in this case the XAML (.xaml.cs) and the CS (.cs) files.
Now add a new UserControl to the solution. It will be named UserControl1.
Without making any changes to the XAML, change the code behind for the MainWindow:
public partial class MainWindow : UserControl1
{
//Code here
}
Now you'll get the exception you questioned about.
Look for something like this in your code, if you still can't find a solution, please provide more code.