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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:56:45+00:00 2026-05-25T22:56:45+00:00

Experts, In XAML I would like to create a many-to-many relationship between entities. Basically

  • 0

Experts,

In XAML I would like to create a many-to-many relationship between entities.

Basically I would like for multiple “Manager” objects to be able to manage multiple “Items”. The following XAML should describe what I’m looking for:

<Grid>
    <Grid.Resources>
        <cc:Manager x:Key="Manager1"/>
        <cc:Manager x:Key="Manager2"/>
    </Grid.Resources>
    <cc:Item>
        <cc.Manager.ManagedBy>
            <StaticResource ResourceKey="Manager1" />
        </cc.Manager.ManagedBy>
    </cc:Item>
    <cc:Item>
        <cc.Manager.ManagedBy>
            <StaticResource ResourceKey="Manager1" />
            <StaticResource ResourceKey="Manager2" /> <!-- ERROR HERE -->
        </cc.Manager.ManagedBy>
    </cc:Item>
    <cc:Item>
        <cc.Manager.ManagedBy>
            <StaticResource ResourceKey="Manager2" />
        </cc.Manager.ManagedBy>
    </cc:Item>
</Grid>

The attached property (Manager.ManagedBy) is of type ManagedByCollection…

ManagedByCollection : List<ManageBy>

With this I get the following error message:

The object 'Object' already has a child and cannot add 'StaticResourceExtension'. 'Object' can accept only one child. Line NN Position NN.

So, I wen’t back to MSDN and realized there’s a ContentPropertyAttribute to tell the XAML compiler what property is the default one when nothing else is specified. The LinearGradientBrush, for example, uses that attribute to enable us to write just …

<LinearGradientBrush ... >
   <GradientStop ... />
   <GradientStop ... />
   <GradientStop ... />
</LinearGradientBrush>

… instead of …

<LinearGradientBrush ... >
   <GradientStopCollection>
       <GradientStop ... />
       <GradientStop ... />
       <GradientStop ... />
   </GradientStopCollection>
</LinearGradientBrush>

So, I was thinking I just needed to specify the indexer of ManagedByCollection as the class’ ContentProperty:

[ContentProperty("Item")
ManagerCollection : List<Manager>

Unfortunately, this does not resolve the issue. Currently the following works…

<cc.Manager.ManagedBy>
    <ManagerCollection>
        <StaticResource ResourceKey="Manager1" />
        <StaticResource ResourceKey="Manager2" />
    <cc:ManagerCollection>
</cc.Manager.ManagedBy>

… but, again, I would prefer the more readble syntax:

<cc.Manager.ManagedBy>
    <StaticResource ResourceKey="Manager1" />
    <StaticResource ResourceKey="Manager2" />
</cc.Manager.ManagedBy>

Any help or hints would be 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-25T22:56:46+00:00Added an answer on May 25, 2026 at 10:56 pm

    You can initialize the collection explicitly in the constructor of Item:

    public Item()
    {
        Manager.SetManagedBy(this, new ManagedByCollection());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create 3 columns (dock-able) on left side of window using XAML.
Yoyo experts! I have several progressbars on my Windowsform (NOT WPF), and I would
Experts, I have JQGrid with custom template column like Edit. the following screen display
With sincere help from experts in this wonderful forum, I have been able to
Hello javascript experts! I'm a novice here, trying to create a script to add
experts. I'm trying to create a simple file downloader (with GUI). I'm pretty new
experts,i wonder the intel x86 machineCode/assemblyCode conversion is singleSide or bothSide? means: assemblyCode --->
Experts - I need some advice in the following scenario. I have a configuration
Hi experts I want to know in which scenario I have more Performance(Time to
PHP experts, I've been working on this problem for about a day and a

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.