WPF - How to edit points in a PolylineCollection.

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

I'm creating a sample project where I will adorn a Polyline with thumbs so I
can resize it by dragging its ends (and points) around. This is similar to
some projects I've posted using a ResizingAdorner class.



I've successfully adorned one end of the Polyline with a thumb so far. Now
when I drag the thumb I need to edit the point in the Polyline where the
thumb is attached (located). This is the first point in the collection. I
haven't found any way to access that point and change it's X/Y values. All
work is being done programmatically in c# and not xaml.



Can someone advise me here?



Also, do you know of any code samples or sample projects which resize and
move Polylines around? I'm trying to create something similar to the right
angle connectors in Visio.



Thanks.
 
Hi moondaddy,

Polyline has a property named Points which is of type PointCollection. You
need to know which point the Thumb is adorned to move the point around. I
think you could attach a property to Thumb and save the point index there.
When the Thumb is moved around, then you could retrieve the index and use
the index to determine which point to move. A point has x and y coordinates.

Sorry I didn't find any examples on such functionality.

Hope this helps.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thanks Walter.

I'm pretty close to this solution now. My obstacle is how to access that
point in the collection. rather than attaching a property to thumb, I
subclassed it so I could add a bunch of extra functionality which includes
the point.

OK I just got it. After a good nights sleep, this is what I learned.

I was trying to access the point in the collection from something like an
item 'collection.items(0)'. the problem is that I'm still trying to write
like VB. I just realized I can get to the item like this:
collection[0]=pt. (... still new to c# & wpf). I'm storing both the point
and its collection index in the subclassed thumb which makes this easy to
use.

You have been a huge help on this project. Have a great weekend!
 
Back
Top