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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:31:15+00:00 2026-05-16T02:31:15+00:00

Well im trying to create a custom container class that contains in my case

  • 0

Well im trying to create a custom container class that contains in my case ViewMappingEntry’s, so i created a class that inherits Freezable and implements ICollection.. but when creating an instance in Blend and browsing it i get this error: Cannot add content to an object of type ‘ViewModelMapping’..

Note: It compiles fine and i get no error in Visual studio, so what am i missing?

public class ViewModelMapping : Freezable, ICollection<MappingEntry>
{
    object locker = new object();

    List<MappingEntry> internalList = new List<MappingEntry>();

    #region ICollection<MappingEntry> Members

    public void Add(MappingEntry item)
    {
        if (this.IsFrozen || this.IsSealed)
            throw new InvalidOperationException("ViewModelMapping is frozen");
        lock (locker)
            internalList.Add(item);
    }

    public void Clear()
    {
        if (this.IsFrozen || this.IsSealed)
            throw new InvalidOperationException("ViewModelMapping is frozen");
        lock (locker)
            internalList.Clear();
    }

    public bool Contains(MappingEntry item)
    {
        lock (locker)
            return internalList.Contains(item);
    }

    public void CopyTo(MappingEntry[] array, int arrayIndex)
    {
        lock (locker)
            internalList.CopyTo(array, arrayIndex);
    }

    public int Count
    {
        get 
        {
            lock (locker)
                return internalList.Count;
        }
    }

    public bool IsReadOnly
    {
        get { return base.IsFrozen || base.IsSealed; }
    }

    public bool Remove(MappingEntry item)
    {
        if (this.IsFrozen || this.IsSealed)
            throw new InvalidOperationException("ViewModelMapping is frozen");
        lock (locker)
            return internalList.Remove(item);
    }

    #endregion

    #region IEnumerable<MappingEntry> Members

    public IEnumerator<MappingEntry> GetEnumerator()
    {
        lock (locker)
            return (IEnumerator<MappingEntry>)internalList.ToArray().GetEnumerator();
    }

    #endregion

    #region IEnumerable Members

    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
    {
        lock (locker)
            return internalList.ToArray().GetEnumerator();
    }

    #endregion

    protected override Freezable CreateInstanceCore()
    {
        ViewModelMapping viewModelMapping = new ViewModelMapping();
        lock(locker)
            viewModelMapping.internalList = new List<MappingEntry>(this.internalList.ToArray());

        return viewModelMapping;
    }
}
  • 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-16T02:31:16+00:00Added an answer on May 16, 2026 at 2:31 am

    after trying around i found a solution if i implemented all these interfaces -> ICollection, IList, IList, ICollection, IEnumerable it started working in blend.

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

Sidebar

Related Questions

I am trying to create a UML class diagram and corresponding class definition (in,
I created a custom membership provider and am getting the following error trying to
I'm trying to do custom serialization/deserialization of an object as well as compressing/decompressing the
I'm trying to create a drawable on the fly to use as a background
I am trying to figure out the best design for a custom floating pallet
I have a small custom object defined as: public class TimeSeriesDefinition { public int
I am trying to use a textarea form entry which I have some javascript
I'm trying to add line numbers to a JTextArea and am having some difficulties.
I'm new to ASP.NET, C# and the MVC framework but have managed to build
Does Castle Windsor support applying setter injection to existing service instances? I have 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.