Handle outgoing links in Xamarin WebView

When coding a Xamarin app that used a web view, I needed certain links to open in the existing view and some to open in Safari instead. To do this, you need to hook into the event on navigating for the web view. I then create a white-list of allowed URLs and check the target of the event. Edit the XAML code-behind file in the main Xamarin project and adjust the constructor as: The Device.OpenUri call will force opening Safari instead.

read more

Plugin: Ensure Single Event Handler

As an update to "Ensuring single instance of event handlers", I wrote a plug-in to handle this as well. The point is, you could useoffandonbut what if there are several handlers? You will risk overwriting other events on the item. For example: This could cause issues when several events are attached to the same object. So instead, we use this: The "attach" method is my custom plugin.

read more