Skip to main content

Microsoft Silverlight

Custom Path or something similarRSS Feed

(0)

Qbus
Qbus

Member

Member

607 points

269 Posts

Custom Path or something similar

Hi

I have a problem I need help to get pointed in the right correction for. I have a "background" image for my Silverlight application. This image is pretty complicated, so I'm not interested in recreating the image in XAML. Therefore I will have the image as a background, and then do some on top of it, to make it interactive.

The image have a structure like this:

I have some "point" which are connected with some paths. (The paths in the real image is straight, not defuse like my quick drawing here :) )

What I need to do it so be able to do something when the mouse if hover over one of these lines and something else when you click on one of the lines. Besides this, all the lines are "unik" in that way, that they all have an "id" that I need to be able to access and look at in the mouse events or something similar. Basically the mouse events need to do different things based on the "id" on this "path/line" or what ever we calling it.

 

I have an idea of how this could be done, just don't know how to start on this in Silverlight.

My idea is that I could maybe create a "Custom Path" class or something like that. Then I could draw up all these "paths" manually (I need to do it manually and this is ok, it isn't THAT many paths anyway). But how is this doable and is it doable, or does I need to do something different?

 :)

 

Thanks in advance,

Qbus

--------------------------
Please mark the post as answered if this answers your question
http://www.laumania.net

Qbus
Qbus

Member

Member

607 points

269 Posts

Re: Custom Path or something similar

 Hmm really no who has an idea? :)

I tryed out making my own Path by inherit from Path, but thats not possible as it is sealed...

--------------------------
Please mark the post as answered if this answers your question
http://www.laumania.net

StefanWick
StefanWick

Contributor

Contributor

2864 points

438 Posts

Microsoft

Re: Custom Path or something similar

Did you look into using a UserControl for your purposes? The control could use a Canvas at its root that 'knows' how to render your data (using Line and Ellipse shapes) and 'knows' how to behave when the mouse interacts with those.

Thanks, Stefan Wick

Microsoft Silverlight | http://blogs.msdn.com/swick/

damonpayne
damonpayne

Member

Member

304 points

75 Posts

Re: Custom Path or something similar

Depending on what interactions you need, it sounds like a custom Border (with the image as its child) withThumbs is what youre looking for, for example to resize the image?

If that's what you're going for, check out the code here (near the end) :

http://www.damonpayne.com/2008/10/07/RunTimeIsDesignTimeForAGT12.aspx

-Damon
http://www.damonpayne.com/

Qbus
Qbus

Member

Member

607 points

269 Posts

Re: Custom Path or something similar

StefanWick:

Did you look into using a UserControl for your purposes? The control could use a Canvas at its root that 'knows' how to render your data (using Line and Ellipse shapes) and 'knows' how to behave when the mouse interacts with those.

Thanks, Stefan Wick

 

Thanks for your reply. I don't think I can use an UserControl because the UserControl can't know how the it will be rendered. Maybe I didn't explained my problem good enough...

The red lines in my picture above have all different kind of shapes and sized. So it's not possible for me to just create an Rectagle in a UserControl and place that on the right places.

This is why I need to draw all the lines up manually, which is ok, I just need all the lines I draw to act similar when the mouse is hoveren for instance. At the same time I need to know the lines from each other, as I need to do different kind of things when the user presses them.

--------------------------
Please mark the post as answered if this answers your question
http://www.laumania.net
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities