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 8809837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:58:35+00:00 2026-06-14T02:58:35+00:00

I got a weird warning that I don’t understand. I have two UserControls .

  • 0

I got a weird warning that I don’t understand.

I have two UserControls. The first one BaseControl inherits from Button and the second SecondControl inherits from BaseControl.
I didn’t change anything so both UserControls are like VS2012 creates them (default constructor etc.) I only removed the sealed keyword of BaseControl in order to inherit it.

Now if I build the project the following warning is put out:

'MyProject.Controls.SecondControl.Connect(int, object)' hides inherited member
'MyProject.Controls.BaseControl.Connect(int, object).' Use the new keyword if hiding was intended.

When I click on this warning, VS2012 opens a file named 'SecondControl.g.cs' and shows this:

partial class SecondControl: global::MyProject.Controls.BaseControl, global::Windows.UI.Xaml.Markup.IComponentConnector
{
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Windows.UI.Xaml.Build.Tasks"," 4.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]

    public void Connect(int connectionId, object target)
    {
        this._contentLoaded = true;
    }
}

What does this mean? I don’t have any method called Connect() except for this in SecondControl.g.cs but that is none of my methods.
Any hint how to fix this? Even it is only a warning and my application works fine, I don’t like to have any warnings/errors in the output window 🙂

I found some articles about this error on SO but none of these helped me 🙁

Edit: Adding the whole classes mentioned above.

BaseControl:

namespace MyProject.Controls
{
    public partial class BaseControl : Button
    {
        public BaseControl()
        {
            this.InitializeComponent();
        }
    }
}

SecondControl:

namespace MyProject.Controls
{
    public sealed partial class SecondControl: BaseControl
    {
        public SecondControl()
        {
            this.InitializeComponent();
        }
    }
}

I checked the whole inheritance chain of Windows.UI.Xaml.Controls.Button and there is no Connect(int, object) or any other Connect(). I didn’t add any Connect()-method too.

  • 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-14T02:58:36+00:00Added an answer on June 14, 2026 at 2:58 am

    You can’t create a control from a UserControl and have it be a Button AND have derived controls. The BaseControl needs to be a sealed UserControl. You could make the UserControl act like a button and/or contain a button.

    The docs for IComponentContainer are partially the clue as to why things are going wrong.

    It’s trying to wire up the UI using the Connect method that is added to the generated class for UserControls. But, by having multiple classes defined for the same XAML (or different XAML), it’s generating the Connect method for each class (BaseControl and SecondControl in your example). That’s why it was sealed to begin with: to prevent this from happening. You can’t reliably have a UI in XAML used by one class and then create a derived class easily. As you can see, the build and VS gets messed up (it’s had this problem for many years with WinForms, WPF, ASP.NET WebForms, and Silverlight).

    What you likely want to do instead is to create a Templated Control. This gives you the ability to define a UI still in XAML (and modify it in subclasses potentially). That’s how the button was originally created in the WinRT (and its ancestors Silverlight and WPF).

    You’ll end up creating a Style in a ResourceDictionary:

    <Style TargetType="local:CustomControl1">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:CustomControl1">
                    <Border
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    

    And a class that uses that Style:

    public sealed class CustomControl1 : Control
    {
        public CustomControl1()
        {
            this.DefaultStyleKey = typeof(CustomControl1);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just implemented QuickSort algorithm from book and got weird output. It works but
I've got a weird issue that almost seems like a Visual Studio 2008 issue.
Heads up: This is a weird question. I've got some really useful macros that
I just had some weird behavior from a version of g++ for Windows that
I got very weird issue with managedObjectContext:save. It hasn't happened at the first time
Got a weird one. I've managed a bring it down to a very simple
I got a weird problem with certificate request that I submit successfully, but when
We've got a weird problem while migrating our app from 1.3.7 to 2.0.0. Our
I got something weird happening here and I can't understand why, on my php
I got weird behavior from ruby (in irb): irb(main):002:0> pp LS 600 \302\240\302\240\302\240\302\240LS 600

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.