void Web(object sender, System.EventArgs e) { var printTemplate = new PrintTemplates.ListPrintTemplate(); // Set the model property (ViewModel is a custom property within containing view - FYI) printTemplate.Model = ViewModel.Prints.ToList(); // Generate the HTML var htmlString = printTemplate.GenerateString(); // Create a source for the webview var htmlSource = new HtmlWebViewSource(); htmlSource.Html = htmlString; // Create and populate the Xamarin.Forms.WebView Navigation.PushAsync(new WebPage(htmlSource)); }
void PrintList(object sender, System.EventArgs e) { // New up the Razor template var printTemplate = new PrintTemplates.ListPrintTemplate(); // Set the model property (ViewModel is a custom property within containing view - FYI) printTemplate.Model = ViewModel.Prints.ToList(); // Generate the HTML var htmlString = printTemplate.GenerateString(); // Create a source for the webview var htmlSource = new HtmlWebViewSource(); htmlSource.Html = htmlString; // Create and populate the Xamarin.Forms.WebView var printService = DependencyService.Get <IPrintService>(); printService.Print(webView); }