Posts

Showing posts from May, 2018

UWP WebView Intermittently Fails to Load in a Xamarin.Forms App - Resolved!

As I've previously mentioned I've been porting an existing Xamarin.Forms app over to UWP and tonight I've had to tackle an annoying bug which was quite difficult to overcome and I thought worthwhile sharing. The bug occurs when loading WebViews with HTML directly rather than a URL. I found that roughly 1 in 5 page loads ended up a blank page being rendered. As this is now the third platform for the App I was fairly confident the html and everything was correct. First of all I suspected a layout issue and maybe the width/height was being messed up so I added a background colour to the control but this always rendered. So not a layout issue. A quick Google led me to Johan Karlsson's post on events needing to be added on the main UI Thread  this seemed better at first but i ended up still hitting the issue 1 in 10 page loads.  More googling led me to a Xamarin bug with the issue  but no resolution :( Taylor Buchanan comments on the bug with a work around however I

Auto Collapsing Master Panel inside Xamarin.Forms UWP app.

Recently I've been migrating a Xamarin.Forms application which works on phones and tablets over to UWP so that its compatible with Windows 10 and available on the desktop. Most things have ported well and after a few tweaks most things are running. However during testing I noticed something odd. I use a master detail page to provide a navigation pane and then a details pane. On phones the navigation page is shown and hidden as expected. On tablets if landscape the menu is always open and if portrait it pops up over the details. Now on UWP it behaves as the tablet however I also expected if the window became small or docked to the side of the screen the menu would again turn into a pop over, but Xamarin.Forms doesn't support this by default. It is however quite easy to support this via a custom renderer. We can override the elements size changed and determine the size of the element. If the size is less than the minimum we want the menu to be automatically opened for we can