Different base class in the XAML file
I have a class called BIFUserControl which inherits from UserControl class. Now I am designing a new user control called BIFText which inherits from BIFUserControl class. So, I changed the XAML file called BIFText.xaml as follows :
<base:BIFUserControl xmlns:base="clr-namespace:BaseInputFramework.BaseWidgets;assembly=BaseInputFramework" x:Class="BIFWidgetLibrary.Text.BIFText" 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" xmlns:mp="clr-namespace:Microsoft.Multipoint.Sdk.Controls;assembly=Microsoft.Multipoint.Sdk.Controls" xmlns:utils="clr-namespace:BaseInputFramework.BaseWidgets.Utils;assembly=BaseInputFramework" mc:Ignorable="d" d:DesignHeight="150" d:DesignWidth="150"> <Grid> </Grid> </base:BIFUserControl>
And then I changed my BIFText.xaml.cs file as follows:
namespace BIFWidgetLibrary.Text { public partial class BIFText : BIFUserControl { public BIFText() { InitializeComponent(); } } }
But now when I try to build the project, I get the following error message : 'BaseInputFramework.BaseWidgets.BIFUserControl' cannot be the root of a XAML file because it was defined using XAML. Line 2 Position 14.
Can someone please help me with this error. Thanks in advance.
Answers
Error says itself that BaseInputFramework.BaseWidgets.BIFUserControl cannot be root of a XAML file since it is defined using XAML. Only elements which are not defined using XAML file can only be root element. Refer to these links - Cannot define root element and Inheriting from UserControl