0

Let's say, I have combined 2 geometries

var combined = Geometry.Combine(geometry1, geometry2, GeometryCombineMode.Intersect, null);
if (combined.Figures.Count > 0)
    combined.Figures[0].IsClosed = false; // throws exception

An unhandled exception of type 'System.InvalidOperationException' occurred in WindowsBase.dll

Additional information: Cannot set a property on object 'M0;50,.....z' because it is in a read-only state.

In debugger

geometry1.IsFrozen = false;
geometry2.IsFrozen = false;
combined.IsFrozen = false;
combined.Figures.IsFrozen = false;
combined.Figures[0].IsFrozen = true; // wtf?

What would be the proper way to unfreeze that figure?

I am trying to solve this issue.

Community
  • 1
  • 1
Sinatr
  • 20,892
  • 15
  • 90
  • 319
  • Is this a new issue or is this an update to your original question? if the latter, then you would be better to update that question. – Sayse Aug 29 '14 at 10:14
  • @Sayse, yes and yes. It's separate issue, which may (I don't know yet) resolve my original problem. There could be possible *other* solutions to original question, that's why I decide to make a new question, which address more specific problem. – Sinatr Aug 29 '14 at 10:22
  • unfreezing is not an option, you may perhaps assign a new updated copy. – pushpraj Aug 29 '14 at 11:47
  • @pushpraj, any idea of how to do it? I can't find `Parse` or `Copy` methods. – Sinatr Aug 29 '14 at 12:31
  • 2
    many classes provide clone method. so if you can tell what is the actual need to do the same, may I try to suggest some workaround. – pushpraj Aug 29 '14 at 12:41

1 Answers1

1

As @pushpraj commented, there is a Clone() method to deal with the problem:

var combined = Geometry.Combine(geometry1, geometry2, GeometryCombineMode.Intersect, null);
if (combined.Figures.Count > 0)
{
    var figure = combined.Figures[0].Clone();
    figure.IsClosed = false;
    combined.Figures.RemoveAt(0);
    combined.Figures.Insert(0, figure);
}
Sinatr
  • 20,892
  • 15
  • 90
  • 319