The error that Xamarin gives back: Type Foo not found in xmlns clr-namespace:AmsterdamTheMapV3
The problem is that I am trying to define Foo but whatever I do it doenst work. I think that the problem is inside the xmls:local namespace. Maybe I make a stupid mistake inside my code.
This is a Xamarin.forms project for windows, android and apple.
Xaml file:
<?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="AmsterdamTheMapV3.CityGuide"
xmlns:local="clr-namespace:AmsterdamTheMapV3">
<Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
<ScrollView Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Spacing="0">
<!-- Button1 -->
<Image
x:Name="CityGuideButton1"
Source="shopping_gray.png"
Aspect="Fill"
HorizontalOptions="FillAndExpand"
VerticalOptions ="FillAndExpand"
local:Foo.Tag="button1">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="Categorie_Onclick"
NumberOfTapsRequired="1"/>
</Image.GestureRecognizers>
</Image>
</StackLayout>
</ScrollView>
</ContentPage>
Cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace AmsterdamTheMapV3
{
public partial class CityGuide : ContentPage
{
public CityGuide()
{
InitializeComponent();
}
public class Foo
{
public static readonly BindableProperty TagProperty = BindableProperty.Create("Tag", typeof(string), typeof(Foo), null);
public static string GetTag(BindableObject bindable)
{
return (string)bindable.GetValue(TagProperty);
}
public static void SetTag(BindableObject bindable, string value)
{
bindable.SetValue(TagProperty, value);
}
}
async void Categorie_Onclick(Object sender, EventArgs args)
{
Image cmd = sender as Image;
string txt = Foo.GetTag(cmd);
await Navigation.PushAsync(new CategoriePage(txt));
}
}
}
I hope that somewann can help me.
I can give more info if needed.
thank you in advance!