Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Custom Path or something similar
4 replies. Latest Post by Qbus on October 11, 2008.
(0)
Qbus
Member
607 points
269 Posts
10-09-2008 4:45 PM |
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,
10-11-2008 7:42 AM |
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...
StefanWick
Contributor
2864 points
438 Posts
10-11-2008 10:59 AM |
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
damonpayne
304 points
75 Posts
10-11-2008 11:51 AM |
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
10-11-2008 4:35 PM |
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.