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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:24:29+00:00 2026-05-13T22:24:29+00:00

WPF controls have certain properties (UserControl.Resources, UserControl.CommandBindings) that can have items added to them

  • 0

WPF controls have certain properties (UserControl.Resources, UserControl.CommandBindings) that can have items added to them from the XAML of a user control declaration. Example:

<UserControl ... >
  <UserControl.CommandBindings>
    ...
  </UserControl.CommandBindings>

  <UserControl.Resources>
    ...
  </UserControl.Resources>
</UserControl>

I have a new list property defined in my user control:

public partial class ArchetypeControl : UserControl {
  ...
  public List<Object> UICommands { get; set; }

I want to add items to this list like I can with resources and CommandBindings, but when I do this:

<c:ArchetypeControl.UICommands>

</c:ArchetypeControl.UICommands>

I get the error “Error 4 The attachable property ‘UICommands’ was not found in type ‘ArchetypeControl’. “

Suggestions?

–

Given the comments, I’ve created a test control to show the entire code and reproduce the problem. I’m using visual studio 2010.

<UserControl x:Class="ArchetypesUI.TestControl"
         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:c="clr-namespace:ArchetypesUI"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">

    <c:TestControl.TestObject>

    </c:TestControl.TestObject>

    <Grid>

    </Grid>
</UserControl>

–

namespace ArchetypesUI
{
    /// <summary>
    /// Interaction logic for TestControl.xaml
    /// </summary>
    public partial class TestControl : UserControl
    {
        public Object TestObject { get; set; }

        public TestControl()
        {
            InitializeComponent();
        }
    }
}

Now the error I get is “Error 2 The attached property ‘TestControl.TestObject’ is not defined on ‘UserControl’ or one of its base classes.”

  • 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-13T22:24:30+00:00Added an answer on May 13, 2026 at 10:24 pm

    Take a look at your XAML:

    <UserControl>
     ^^^^^^^^^^^
        <c:TestControl.TestObject>
           ^^^^^^^^^^^
        </c:TestControl.TestObject>
    </UserControl>
    

    Here, you are declaring a UserControl, and then trying to set a TestControl property on it. Since UserControl doesn’t have the TestControl.TestObject property, WPF that it can’t set that property on the UserControl object. You may say, “But I’m declaring a UserControl of type TestControl. My UserControl is a TestControl!” But that’s not quite the case. The above declaration is declaring the TestControl class: it’s not creating an instance of TestControl, so it can’t have instance properties set on it.

    Rather, the TestObject property is there for users of TestControl to set on individual instances of TestControl:

    <local:TestControl>
      <local:TestControl.TestObject>  <!-- Now it will work -->
      </local:TestControl.TestObject>
    </local:TestControl>
    

    If you want to set a default / initial value for the TestObject property, then you can do so either in the TestControl constructor, or (if TestObject is a dependency property) through the TestControl default style (though this is more for custom controls than for user controls).

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

Sidebar

Related Questions

I have a WPF Window which has a among other controls hosts a Frame.
I have a WPF control, that has a list of Investors, and in the
The WPF control WindowsFormsHost inherits from IDisposable. If I have a complex WPF visual
Using WPF, I have a TreeView control that I want to set its ItemTemplate
If you have a WPF control library which you wanted to license to developers,
Each item in a WPF ListBox control seems to have a bit of left
So, I have a WindowsFormsHost control in my WPF app (hosting a Dundas Chart)
Some WPF controls (like the Button ) seem to happily consume all the available
In Charles Petzold's Using Templates to Customize WPF Controls article in the Jan 2007
Hey, i'm extending some WPF controls, and need to implement some custom events. I've

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.