I recently had a client who wanted to create simple reports that consisted of a variable number of columns, followed by a “more” button that takes you to a page with the full details.
The problem was that they didn’t want to hard-code anything. They wanted the ability to add reports without sending out a new version of the software, and they wanted to be able to pick which columns were visible. Yikes!
Jeffrey T. Fritz is a senior program manager in Microsoft’s Developer Outreach Group that works with the community on open source projects and the new Microsoft .NET Core framework. As a long time web developer with experience in large and small applications across a variety of verticals, he knows how to build for performance and practicality. More recently, he has worked closely with developers to teach them to succeed with new tools and frameworks from Microsoft and Telerik
In a recent project, I found myself needing multiple, seemingly unrelated databases. It was crazy to copy and paste the code for such basic operations as getting all the data, etc., so the obvious alternative was a generic repository, and a database with tables for each set of data.
The first step is creating the SQLite repo. We begin by creating the class:
public class GenericSqliteRepository<T> where T : IEntity, new()
It is fairly easy to display a PDF file that is local to your phone. For example, see this article from Xamarin.com.
A bit trickier is to get a PDF from a server and then to display it. Here’s how I did it (note, this blog post offers snippets of code, rather than a complete solution… I will reduce my larger program to something manageable asap)
The first thing I did was create a model object named ReportItem. Its primary goal is to help group all the items in my list of pdf’s, but it contains the all-important URL to the pdf itself.
Next, I created a page named ShowPDFPage. In the XAML part of this page I just have a CustomWebView: