I want to derive a control from a derived user control but having problems with the xaml resolving it. However, first the simple scenario. I have a library MyControls.dll. In that, I have a control based on "UserControl" in a .cs file such as
public class MyUserControl : UserControl { ... }
No problem. Now, I want to create a second (VISUAL) control derived from this... So, I do a new UserControl called NewFromMyUserControl.xaml.cs and NewFromMyUserControl.cs respectively in this same MyControls.dll library such as
public partial class NewFromMyUserControl : MyUserControl { ... }
Now, in the Xaml, I have...
<mylib:MyUserControl x:Class="MyControls.SubFolder1.NewFromMyUserControl"
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:mylib ="clr-namespace:MyControls" (blah blah) />
</mylib:MyUserControl>
This works no problem. And for simplicity purposes, no actual code in the "MyUserControl" or the "NewFromMyUserControl" classes... just testing derived implementation.
NOW, the problem. I have another library "MyBaselineControls.dll" which has the actual UserControl I want derived from... such as
public class MyBaselineUserControl : UserControl { ... }
and Now, I want to change the "MyUserControl" to be derived from this other such as
from
public class MyUserControl : UserControl { ... }
to
using MyBaselineControls;
public class MyUserControl : MyBaselineUserControl { ... }
As soon as this one line changed, the compiler fails stating...
Error 2 'MyControls.MyUserControl' cannot be the root of a XAML file because it was defined using XAML. Line 1 Position 19. ... blah blah
Are there issues of deriving from derived of another library?
Thanks