Я новичок в Xamarin и не большой поклонник WPF.Я беру курс по Udemy, и инструктор показывает, как ловить ошибки xaml во время компиляции.Проблема в том, что текущая версия Xamarin, поставляемая с VS 2019, не улавливает ошибку.Я некоторое время гуглял, и все, что я придумал, это попробовать глобальный обработчик исключений и сказать компилятору скомпилировать xaml в файле assembly.cs (который теперь используется по умолчанию).Кто-нибудь может указать мне правильное направление?
Вот моя страница Xaml - TypeArgumen должен быть недействительным:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="HelloWorld.GreetPage">
<ContentPage.Padding>
<OnPlatform x:TypeArgumen="Thickness"
Android="0,0,0,0"
iOS="0,30,0,0">
</OnPlatform>
</ContentPage.Padding>
<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>
</StackLayout>
Вот мой файл assembly.cs:
using Xamarin.Forms.Xaml;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
Вот мой код:
using System;
using System.Collections.Generic;использование System.Linq;используя System.Text;использование System.Threading.Tasks;
использование Xamarin.Forms;используя Xamarin.Forms.Xaml;
namespace HelloWorld
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class GreetPage : ContentPage
{
public GreetPage()
{
InitializeComponent();
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;
Console.WriteLine(ex);
};
}
}
}