Xamarin.Forms.Xaml.XamlParseException: MarkupExtension not found

I am trying to use my own markup extension with Xamarin formats in order to eventually implement localization. I am trying to do a long series of Xamarin form examples.

Here is a piece of XAML code that uses the extension:

<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:CRI.MAP.Mobile.Views;assembly=CRI.MAP.Mobile" x:Class="CRI.MAP.Mobile.Views.CustomerSearchPage"> <StackLayout> <Button Text="{local:Translate Clear}" Command="{Binding ClearCommand}" /> </StackLayout> 

Here is the code for extending translation extensions:

 using System; using Xamarin.Forms.Xaml; using Xamarin.Forms; using System.Diagnostics; namespace CRI.MAP.Mobile.Views { // You exclude the 'Extension' suffix when using in Xaml markup [ContentProperty ("Text")] public class TranslateExtension : IMarkupExtension { public string Text { get; set; } public object ProvideValue (IServiceProvider serviceProvider) { //if (Text == null) // return null; //Debug.WriteLine ("Provide: " + Text); // Do your translation lookup here, using whatever method you require //var translated = L10n.Localize (Text); //return translated; return "hello"; } } } 

I commented on some of the code in case this was causing the problem.

Whenever I try to run this, I get an error: Xamarin.Forms.Xaml.XamlParseException: MarkupExtension not found for local: Translate. I am very confused why it does not find the markup extension, since all the examples I look at look the same. Does anyone know why this would be? I have many problems, in general, find good examples for Hamarin's forms.

+5
source share
1 answer

Invalid assembly name. I used a generic project for Xamarin forms and had the name of the collaborative project as the assembly name. Therefore, if you have a common project, the assembly name should be an assembly that uses a common project.

+4
source

Source: https://habr.com/ru/post/1205879/


All Articles