Switch branches/tags
Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information.
SVG Upgrading to Forms 2.0 Jan 3, 2016
SampleApp Upgrading to Forms 2.0 Jan 3, 2016
README.md Update README.md Sep 5, 2015
SVG.sln Upgrading to Forms 2.0 Jan 2, 2016


Why SVG?



In your Android,iOS and Windows Phone projects call:

Xamarin.Forms.Init();//platform specific init

You must do this AFTER you call Xamarin.Forms.Init();


Instead of using an Image Control simply use SvgImage!

You MUST :

  • Set Height and Width
  • Set Build Action to Embedded Resource for your svg files
  • SvgPath to {Project}.{Folder}.{FileName}.{Extension}
  • SvgAssembly to the assembly containing the file
  • For Win Phone make sure you include a XAML file equivalent of the SVG with the root element being a Viewbox
  • Example : If you have Sample.svg also add Sample.xaml under the same folder of the svg.(No need to specify anything else as long as the names match)

Code Usage :

new SvgImage { 
		SvgPath = "PluginSampleApp.Images.hipster.svg",
		SvgAssembly = typeof(App).GetTypeInfo().Assembly, 
		HeightRequest = 100,
		WidthRequest = 100

Xaml Usage :

  <abstractions:SvgImage Grid.Row="0" Grid.Column="0" SvgAssembly="{Binding SvgAssembly}" SvgPath="{Binding CoolMaskSvgPath}" HeightRequest="50" WidthRequest="50" BackgroundColor="White" HorizontalOptions="Center" VerticalOptions="Center"/>

In the example my SVG file is located under the Images folder in the PluginSampleApp project. The SvgAssembly is a reference to the assembly containing the svg/xaml file.

Where to get SVG/XAML?

Win Phone does not support SVGs by default and there are no good SVG to Win Phone XAML libraries. Diederik Krols has a really nice post on how to convert SVG to Metro XAML. Check out the nounproject for some royalty free SVGs.




Licensed under main repo license