I'm new to Xamarin and not a big fan of WPF. I'm taking a course on Udemy and the instructor is showing how to catch xaml errors at compile time. The problem is, the current version of Xamarin that comes with VS 2019 isn't catching the error. I've been Googling for a while and all I came up with is to try a global exception handler and telling the compiler to compile xaml in the assembly.cs (which is now the default). Can anyone point me in a good direction?

Here is my Xaml page - TypeArgumen should be invalid:

    <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

        <OnPlatform x:TypeArgumen="Thickness"

    <StackLayout BindingContext="{x:Reference slider}" HorizontalOptions="Center" VerticalOptions="Center">

        <BoxView Color="Green" Opacity="{Binding Value}" />

        <Label Text="{Binding Value, StringFormat='Value is {0:F2}'}" 
                Opacity="{Binding Value}" />

        <Slider x:Name="slider"></Slider>

Here is my assembly.cs file:

    using Xamarin.Forms.Xaml;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]

Here is my Code behind:

using System;

using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

using Xamarin.Forms; using Xamarin.Forms.Xaml;

namespace HelloWorld
    public partial class GreetPage : ContentPage
        public GreetPage()

            slider.Value = .5;

            if (Device.RuntimePlatform == Device.iOS)
                Padding = new Thickness(0, 20, 0, 0);
            else if (Device.RuntimePlatform == Device.Android)
                Padding = new Thickness(0, 5, 0, 0);

            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
                System.Exception ex = (System.Exception)args.ExceptionObject;

0 Answers