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

  • SEARCH
  • Home
  • 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 706497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:10:23+00:00 2026-05-14T04:10:23+00:00

All, I have a simple class. public class Container : UserControl { public bool

  • 0

All,

I have a simple class.

public class Container : UserControl
{
    public bool IsClickable { get; set; }
}

I have a class that extends this class.

public class ScrollingContainer : Container
{
    public void Draw()
    {

    }

    public void Update()
    {

    }
}

I have a custom class, that then extends ScrollingContainer.

public partial class MaskContainer : ScrollingContainer
{

    public MaskContainer()
    {
        InitializeComponent();
    }
}

XAML

<local:ScrollingContainer x:Class="Test.Types.MaskContainer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:GameObjects;assembly=GameObjects"
    mc:Ignorable="d"
    >
</local:ScrollingContainer>

In my mainpage.xaml, I have the following.

<types:MaskContainer x:Name="maskContainer" Canvas.ZIndex="1" Width="Auto" Height="Auto">
       <Canvas x:Name="maskCanvas">
           <Button x:Name="button1" Content="test button"/>
       </Canvas>
</types:MaskContainer>

Why, at runtime, are both maskCanvas and button1 null? maskContainer is not null.

The inheritance should be straightforward here. Container inherits usercontrol. Scrollable container inherits container. Mask Container inherits scrollable container. Why am I losing the functionality of the original base class at this level? Is it incorrect to add the element (button1) to the maskcontainer inside of the main.xaml?

My end goal is to create a container that is reusable, but inherits all properties/methods that I’ve specified throughout the chain.

Any help is appreciated.

  • 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-05-14T04:10:24+00:00Added an answer on May 14, 2026 at 4:10 am

    The problem is, MaskContainer has an attached XAML file, which makes the WPF codegen generate a class that implements System.Windows.Markup.IComponentConnector. And when a control implements that interface, it receives a whole new quality: it becomes a naming scope root. Which means that inside such a control, there is a whole separate naming space. Control names outside do not conflict with inside ones.

    In this particular case, that means that both maskCanvas and button1 are not visible from within mainpage by name, but are visible from within MaskContainer instead.

    In fact, I’m very surprised that you’ve even managed to get this compiled somehow. From my experience, if you try this trick with Visual Studio, it would complain about maskCanvas being “under scope of element MaskContainer“. Do you use command-line compilation by any chance?

    Ok, so enough blah-blah-blah already.

    What’s the solution? Simply remove XAML file from MaskContainer. That will get rid of autogenerated IComponentConnector implementation, and everything will work as you expect it to.

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

Sidebar

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Dispatch a custom event (like imgLoaded) from the image loading… May 16, 2026 at 4:13 pm
  • Editorial Team
    Editorial Team added an answer Try with simple XML, here's an example: do.php: <?php $xml_str… May 16, 2026 at 4:13 pm
  • Editorial Team
    Editorial Team added an answer input.class { border: 1px solid #ccc; } <input type="text" class="class">… May 16, 2026 at 4:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a DependencyObject class composition that looks like the following: public class A
I have a simple container class with a copy constructor. Do you recommend using
I have a simple UserControl containing Label, ComboBox and Button. In brief, it is
I have written my Container<T> class which backups its T items in several collections
I'm learning C++ and can't get my head around this problem: I have a
I have a class namespace LogToolsTest { public class Foo { private static readonly
I have a class which derived from the TableLayoutPanel. This class makeup the tabel
I have these container objects (let's call them Container) in a list. Each of
Okay so I have two import pieces of code involved in this. This first
While creating a simple client for a REST service which I have stubbed out,

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.