This project has moved and is read-only. For the latest updates, please go here.

WF - Hosting SharpVectors WPF

Topics: SVG
Mar 13, 2015 at 2:46 PM
Edited Mar 13, 2015 at 2:47 PM
Hello,

I want to host an SVG Image in VS.NET - Windows Forms.

I first testet it out in WPF:
<Image Source="{svgc:SvgImage \Images\Image1.svg}"/>

Now I want to create an SvgImage within Windows Forms.
I already informed me about that topic and heard something about an "ElementHost" Object.

I would be very greatful if anyone could help me out.

With friendly Regards
Jan aka. Sonorpearl
Coordinator
Mar 21, 2015 at 11:59 PM
Hello Jan,
SvgImage is a WPF markup extension, you cannot host it in Windows Forms.

Use the SvgCanvas, SvgViewbox etc, which are controls or create your own WPF control that displays the converted
drawing DrawingGroup and host it in the Windows Forms.

Best regards,
Paul.
May 7, 2015 at 7:19 AM
Edited May 7, 2015 at 7:22 AM
HeyHo Paul,

it is nice that you tried to help me, but it aint saying me anything right now.
It would be very nice if you could show me what you are meaning.

My situation is that we have complete Software in VB.NET 2010 in Windows Forms and we need to add some SVG we created for another branch.

With friendly Regards
Jan aka. Sonorpearl
Coordinator
May 17, 2015 at 5:00 PM
Edited May 17, 2015 at 5:17 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
May 17, 2015 at 5:17 PM
Hello Jan,
I have copied this to the Work Item so that I could add the sample you are looking for. Hopefully this will solve your problem.

To make this easier and manageable, I created a simple class, SvgHostElement, which inherits from ElementHost object that holds the WPF control as a child, SvgCanvas (or SvgDrawingCanvas) in this case.

NOTE: I override the Designer Smart-Tag and the DesignerSerializer attributes in order to prevent an override of the Child element by the Designer.
If not, the Windows Forms Designer will set the Child of the instance of your host control (svgHostTest in this case) to Nothing, like the following in the generated Designer codes.
Me.svgHostTest.Child = Nothing
and you will not be able to display anything since the WPF Child control is not attached to the host control.

Finally, this type of question are not really meant for this forum, this is is a general WPF issue and by Googling you could easily find a workable solution and/or sample.

Best regards,
Paul.
Marked as answer by Sonorpearl on 5/19/2015 at 2:05 AM