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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:21:23+00:00 2026-05-28T01:21:23+00:00

I’m using Silverlight 5 with MVVM. I have a ViewModel that is a Singleton

  • 0

I’m using Silverlight 5 with MVVM.

I have a ViewModel that is a Singleton. The ViewModel exposes a PointCollection that I am using to draw a Polyline in one of my views.

If I try to draw the same Polyline in a second view, by databinding to the PointCollection again, I get a “value does not fall within the expected range” exception.

As far as I could find out (with my limited Silverlight knowledge), this is caused by the fact that PointCollections are not shareable.

Is there a workaround? How can I get a second Polyline drawn that is identical to the first? I want to databind two Polylines to one PointCollection at the same time.

Edit: I haven’t found a solution, but someone with the same problem here. According to Microsoft:

This MSDN page mentions that some objects are not shareable and will genereate a “value out of range” exception.
http://msdn.microsoft.com/en-us/library/system.windows.resourcedictionary(VS.95).aspx

The PointCollection page also mentions that it is not shareable.
http://msdn.microsoft.com/en-us/library/system.windows.media.pointcollection(VS.95).aspx

Currently, this is by design behavior. However, we are evaluating this to see whether we can either change the behavior or at least the exception text.

  • 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-28T01:21:25+00:00Added an answer on May 28, 2026 at 1:21 am

    Have a look at this question: Why doesn't this data binding work?

    And at this one too: 2nd time binding to PointCollection not being rendered

    As you gave little details I am not quite sure what is going on but these posts might help out. If not, please post your code.

    I did some testing and the best solution I can think of is this:

    using System.ComponentModel;
    using System.Windows;
    using System.Windows.Media;
    
    namespace SilverlightApplication6
    {
        public class DemoVM : INotifyPropertyChanged
        {
            #region PointsClone Property
            private PointCollection _pointsClone;
            public PointCollection PointsClone
            {
                get
                {
                    return _pointsClone;
                }
                set
                {
                    if (_pointsClone != value)
                    {
                        _pointsClone = value;
                        OnPropertyChanged("PointsClone");
                    }
                }
            }
            #endregion
    
            #region Points Property
            private PointCollection _points;
            public PointCollection Points
            {
                get
                {
                    return _points;
                }
                set
                {
                    if (_points != value)
                    {
                        _points = value;
                        PointsClone.Clear();
                        foreach (var point in _points)
                        {
                            PointsClone.Add(point);
                        }
                        OnPropertyChanged("Points");
                    }
                }
            }
            #endregion
    
            public DemoVM()
            {
                PointsClone = new PointCollection();
                Points = new PointCollection();
            }
    
            public void AddPoint(Point point)
            {
                Points.Add(point);
                PointsClone.Add(point);
            }
    
            public void ClearPoints()
            {
                Points.Clear();
                PointsClone.Clear();
            }
    
    
            public event PropertyChangedEventHandler PropertyChanged;
    
            protected void OnPropertyChanged(string propertyName)
            {
                var p = PropertyChanged;
                if (p != null)
                {
                    p(this, new PropertyChangedEventArgs(propertyName));
                }
            }
        }
    }
    

    Bind one PolyLine.Points to Points and the other PolyLine.Points to PointsClone.

    It is a bit ugly because it will break when you use vm.Points.Add(point) instead of vm.AddPoint(point). By applying proper encapsulation you might be able to solve that.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.