Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8721609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:14:57+00:00 2026-06-13T07:14:57+00:00

I want to derive a control from a derived user control but having problems

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:14:58+00:00Added an answer on June 13, 2026 at 7:14 am

    You can’t derive from user controls that have a XAML definition. As long as you don’t define XAML in your base class, you’ll be fine. Specific information about your error can be found here.

    One way to work around it is to derive from Control (or another class derived from Control which is not UserControl) and define a control template for your base and derived controls. This page explains exactly what you can do when you inherit from Control or UserControl, and which things you should consider when deciding on which you’d like to derive from.


    EDIT

    Since you’re saying that both MyBaselineUserControl and MyUserControl don’t define any XAML, things should work. I tried it myself and I had no problems.

    I recommend that you make sure that your base UserControls were actually created with no XAML, i.e. they should have been created with “Add –> Class” and not with “Add –> User Control”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create simple custom control (derived from control and with look defined
I want to create a control (derived from TCustomControl) that is invisible but reacts
The button is derived from user control. I want to associate a pop-up window
I want to create a Custom Control derived from ComboBox , however if I
I want to create a new custom control derived from ContentControl (it will be
I want to create a class which is derived from QLineEdit ,but I can
I have a control derived from ComboBox , I want to use the ComboBox
I want to apply a style to all classes derived from Control. Is this
I want to create a custom control (derived from Control class), and when I
I want to create a custom control derived from TPanel that contains an image

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.