Oct 11, 2014 at 8:07 AM
Edited Oct 11, 2014 at 8:23 AM
I'am trying to change the SvgCanvas.Source property within my C# Code.
I already tried many different ways to load a different SVG file from my Resource folder but with no success.
I have a WPF Application, a Resource folder with three svg files (h1_05.svg, h1_08.svg and komplett.svg). The "komplett.svg" is the init svg file which i could easily set in the XAML-File
MouseDown="Canvas_MouseDown" HorizontalAlignment="Left" VerticalAlignment="Center" />
In the Mouse_Down event i have so change the canvas.source depending on the location the mouse was clicked with a hide and show animation.
private void Canvas_MouseDown(object sender, MouseButtonEventArgs e)
var element = sender as UIElement;
Point pos = e.GetPosition(element);
if ((myController.isValidRoom(pos, rooms)) || (!isSvgKomplett))
DoubleAnimation hide = new DoubleAnimation(1, 0, TimeSpan.FromSeconds(0.5));
hide.Completed += (s, mouseEvent) => hideCompleted(pos);
private void hideCompleted(Point p)
// This is the tricky part where i already tried many different ways
canvas = new SvgCanvas
// At first it would be enough to change the svg file hardcoded
Source = new Uri("pack://application:,,,/Resources/h1_05.svg")
DoubleAnimation show = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(0.5));
The problem is that C# dont accept this syntax and all other trys i made before.
I tried to build the svg files as Resource and as embeded resource but with no success.
Somebody know how to fix this?
kind regards Arthur