から入れ子になったクラスXamarinが戻って与えることがエラーのプロパティを設定することはできませんAmsterdamTheMapV3はXAML
問題は、私がfooを定義しようとしていますということですが、私はそれを行うものは何でもdoenst work。問題はxmls:ローカル名前空間の内側にあると私は思う。たぶん私は自分のコードの中で愚かな間違いをするかもしれない。
これは、Windows、android and apple用のXamarin.formsプロジェクトです。
XAMLファイル:
<?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のファイル:
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));
}
}
}
私はsomewannが私を助けることができることを願っています。
必要に応じてさらに情報を提供できます。
ありがとうございます!
Xamlはおそらくあなたの期待する内容を表示しないことに注意してください。 contentPageには2つの子、 'Label'と' ScrollView'がありますが、 'ContentPage'は' Content'という単一のプロパティしか受け付けません。執筆時点では、Xamarin.Forms Xamlパーサーは非常に寛容で、2つの項目のうちの1つは無視されます(通常は最後の項目を除くすべて)が、将来変更されて投げられる可能性があります。 –
この質問のアップロード後に変更しました。ラベルはそこにあるはずではなかった。しかし、まだフィードバックに感謝します。そして、私はこれを念頭に置いておきます。 –