Last active
March 16, 2017 16:41
-
-
Save hprez21/f9738980e95774a0eaaa93150123db30 to your computer and use it in GitHub Desktop.
Xamarin.Forms: Cargar un archivo html a un WebView.Source (Tomado de la documentación oficial)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@param1 = Clase que contiene el método LoadHTMLFileFromResource | |
//@param2 = Archivo html, partiendo de la estructura del proyecto, por ejemplo: Recetas.test.html | |
//Ejemplo completo en https://github.com/hprez21/Recetas-Xamarin-Forms | |
HtmlWebViewSource LoadHTMLFileFromResource() | |
{ | |
var source = new HtmlWebViewSource(); | |
// Carga el archivo HTML embebido como un recurso en el PCL | |
var assembly = typeof(@parm1).GetTypeInfo().Assembly; | |
var stream = assembly.GetManifestResourceStream("@param2"); | |
using (var reader = new StreamReader(stream)) | |
{ | |
source.Html = reader.ReadToEnd(); | |
} | |
return source; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment