static BindingObjectExtensions() { // This is the current situation, where the LoadFromXaml is the only non-public static method. var genericMethod = typeof(Xamarin.Forms.Xaml.Extensions) .GetMethods(BindingFlags.Static | BindingFlags.NonPublic) .FirstOrDefault(); // If we didn't find it, it may be because the extension method may be public now :) if (genericMethod == null) { genericMethod = typeof(Xamarin.Forms.Xaml.Extensions) .GetMethods(BindingFlags.Static | BindingFlags.Public) .FirstOrDefault(m => m.GetParameters().Last().ParameterType == typeof(string)); } if (genericMethod == null) { LoadXaml = (view, xaml, onError) => { throw new NotSupportedException("Xamarin.Forms implementation of XAML loading not found."); }; } else { genericMethod = genericMethod.MakeGenericMethod(typeof(BindableObject)); LoadXaml = (view, xaml, onError) => { try { return((BindableObject)genericMethod.Invoke(null, new object[] { view, xaml })); } catch (Exception e) { var info = new XamlParseErrorInfo { Message = e.InnerException?.Message ?? e.Message }; onError?.Invoke(info); return(null); } }; } }
public void ShowError(XamlParseErrorInfo info) { DisplayAlert("Design Error #1002", info.Message, "Ok"); }