public object Convert(object value, Type targetType = null, object parameter = null, CultureInfo culture = null) #endif { try { var ctx = (parameter as DataContext).ToNonReadOnly(); if (!string.IsNullOrEmpty(ViewName)) { ctx.AddOrUpdate(NavigationConstants.ViewName, ViewName); } #if ANDROID return(AndroidToolkitExtensions.GetOrCreateView((IViewModel)value, AlwaysCreateNewView, ctx)); #else return(ToolkitServiceProvider.ViewManager.GetOrCreateView((IViewModel)value, AlwaysCreateNewView, ctx)); #endif } catch (Exception exception) when(!ThrowOnError) { Tracer.Error(exception.Flatten(true)); #if ANDROID var txt = new TextView(parameter as Context ?? Application.Context) { Text = exception.Flatten(true) }; txt.SetTextColor(Color.Red); return(txt); #elif TOUCH return(new UITextView(new RectangleF(10, 10, 300, 30)) { TextColor = UIColor.Red, Editable = false, DataDetectorTypes = UIDataDetectorType.None, Text = exception.Flatten(true) }); #elif XAMARIN_FORMS return(new Label { TextColor = Color.Red, Text = exception.Flatten(true) }); #else return(new TextBox { Text = exception.Flatten(true), #if WINFORMS ReadOnly = true, WordWrap = true, ForeColor = Color.Red #else IsReadOnly = true, TextWrapping = TextWrapping.Wrap, Foreground = new SolidColorBrush(Colors.Red) #endif });