this is the serial number of our orbital gun
When UWP comes into play with Xamarin Forms, you notice that several default control settings are often not resulting in a pleasing UI.
One that caught my eye recently was the way the height is set in a grouped lisview header.
So assume following setup, you define a listview and enable grouping. With that you would like to control what is being shown in the header, so you define your own GroupHeader Template. Inside the template, you only need a small display area, so for demo purpose we will only enable a Label control, but are setting it height to a fix amount of 25!Well this is odd! Somehow the height of our headers is larger than what we defined looks like UWP has some default rendering that overrides what we have set.
So after some digging through the source code of Xamarin forms, I not found any special setting that could trigger this. In other words it not something Xamarin does to the UWP rendering of the listview.
This meant I needed to go look at the default template settings of the UWP control itself. What I found was that the listview control has a special header template style defined that uses a specific value for the minimum height for the ListViewHeaderItemMinHeight!
It set to 44 this explains our weird look and feel on UWP.
The definition for this style can be found here this in mind it actually very easy to fix this in our app. All we need to do is provide a better minimum height value for the given style key.
To show of the power of this, let do a fun example.
Wouldn it be nice if you could create Microsoft Office Excel of Word files on the fly inside your Xamarin Forms app? Of course you could offload this to a backend service, but that means you also need to be the owner of the data service. On the other hand creating simple CSV files that are compatible with Excel is also a possibility, but you are limited to only adding data in that case ( no formula or formatting ).
To accomplish this now ( without any new Visual Studio templates ), just create a new blank PCL Xamarin Forms app.
Now you can just delete the old PCL project.
For our example we also need to add the OpenXML nuget package so that we create and manipulate Docx and Xlsx files.
Let assume you have some data in a local database of pulled down from a REST service, it nicely presented on your screen and you can annotate and filter it.
When you are done you want to transfer this set over to some coworker but he is working in another environment and excel would suit better.
So how do we create an Excel file with this data blob?//Create a new spreadsheet file remark will overwrite existing ones with the same name!.