Hmm, instead of drawing the lines and whatnot, have you considered
making the lines (with the associated elements) and rectangles UIElements
themselves? They would have their own dependency properties, etc, etc, and
then you would add them to the canvas.
Then, in relation to your class, you could just have it listen to the
event handlers for the dependency properties you expose and do something
when the value changes.
For example, for a Line class, you would have a Point1 dependency
property and a Point2 dependency property (maybe, it's up to you) which
expose the endpoints of the line. Then, you could just register to receive
change notifications in your class that you want to receive updates.
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
"Wonko the Sane" <Wonko the
(E-Mail Removed)am> wrote in message
news:F6DFDF35-CB80-4EC5-A26D-(E-Mail Removed)...
> Hi All,
>
> I have the following (much-simplified) situation. I have a class, part of
> which involves drawing graphics on a Canvas. I may have a number of
> instances of these graphics, which may include a line, two rectangles used
> as
> endpoints, and perhaps a label for the line.
>
> I want to somehow later associate a graphic on the canvas with an instance
> of the class. For instance, if the user selects an endpoint and drags it,
> I
> want to resize the line, and perhaps update some information in a database
> based on that resize.
>
> I'm just looking for a graceful way to do this. I have a solution, but it
> seems inelegant. Any advice or a pointer to an example would be
> appreciated...
>
> Thanks.