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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:50:23+00:00 2026-06-13T21:50:23+00:00

I have a UserControl, which I have set to Internal as such: UserControl x:Class=ClassName

  • 0

I have a UserControl, which I have set to Internal as such:

UserControl x:Class="ClassName"
             x:ClassModifier="internal"

And it’s matching .cs file:

 internal partial class ClassName : UserControl
    {
        public ClassName()
        {
            InitializeComponent();
        }
    }

Now, when I try to use the control on a window, like this:

 uControls:ClassName x:Name="instanceName" Margin="0,0,8,0" Height="60" VerticalAlignment="Top" Width="60" HorizontalAlignment="Right" MouseLeftButtonUp="instanceName_MouseLeftButtonUp" Cursor="ScrollNW" 

I get an error stating:

The type 'ClassName' cannot have a Name attribute. Value types and types without a default constructor can be used as items within a ResourceDictionary. Line 12 Position 44.

If I change the access modifiers to public, all works as expected.

Why can I not have internal User Controls?

  • 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-13T21:50:25+00:00Added an answer on June 13, 2026 at 9:50 pm

    I believe that this is caused by the compilation model for WPF. I’m quoting this from memory and can’t find a resource to back it up, but I believe that WPF compilation happens in two passes: essentially the “codebehind” portion is compiled first to an intermediate assembly, then the XAML is compiled as referencing that intermediate, and the results are combined to the final assembly.

    For this reason, the classes/members that the XAML references have to be declared publicly, because (as far as the compiler is concerned) they’re in a separate assembly to the XAML.

    EDIT: found a Microsoft reference here that outlines the process. In particular, in terms of supporting what I said above, it says:

    if one or more XAML files in the project have references to locally defined types, then a temporary .dll file is generated so the final application assemblies may be created after the second pass of markup compilation is complete.

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

Sidebar

Related Questions

I have a UserControl SubjectListView. The binding is set to AllSubjects which is an
I have a usercontrol which has a grid control inside <UserControl x:Class=MyGrid> <Telerik:RadGridView EnableRowVirtualization=false>
I have a UserControl which contains a listbox and few buttons. <UserControl x:Class=ItemControls.ListBoxControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
I have a usercontrol which I need to set a specific DataContext on. The
I have a HyperLink on my usercontrol in which I set the onlick event
I have a usercontrol which has a couple of textblocks on it <UserControl x:Class=Tester.Messenger
I have a situation in which ScrollViewer is set in the base class (
I have a UserControl which overrides the OnRender-Method as follow: MyUsercontrol.cs: MyUserControl: UserControl {
I have a UserControl which contains a TextBox . When my main window loads
I have a UserControl which I have added to my web.config <add tagPrefix=BCF src=~/controls/MyMessageBox.ascx

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.