タップジェスチャーでスタックレイアウトから別のラベルを取得する最良の方法は何ですか?私のStacklayoutはグリッドの一部です。タップジェスチャー認識機能でスタックレイアウトからラベルを取得
いいアイデアだとは思えますが、たとえば自分のブランド名のText値を取得するのには役立ちません。
相続人は私のstacklayoutの内容:
Image PictureProduct = new Image { Aspect = Aspect.AspectFit };
PictureProduct.Source = FileImageSource.FromUri(...);
Label BrandName = new Label {Text = "HelloWorld"};
Label Description = new Label { Text = "Hello darkness my old friends..."};
Label Price = new Label { Text = "14,99€"};
StackLayout TheStack = new StackLayout { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, HeightRequest = 425 };
TheStack.Children.Add(PictureProduct);
TheStack.Children.Add(BrandName);
TheStack.Children.Add(Description);
TheStack.Children.Add(Price);
var MyTapGesture = new TapGestureRecognizer();
MyTapGesture.Tapped += (sender, e) =>
{
Debug.Write(/*BrandName of product*/);
};
TheStack.GestureRecognizers.Add(MyTapGesture);
いいアイデアだとは思うが、たとえば自分のブランド名のテキスト値を取得するのに役立たない。 私のstacklayoutの内容を聞きます: Image PictureProduct = new Image {Aspect = Aspect.AspectFit}; PictureProduct.Source = FileImageSource.FromUri(...); Label BrandName =新しいラベル{Text = "HelloWorld"}; Label description = new Label {Text = "こんにちは、昔の友よ..."}; ラベル価格=新しいラベル{Text = "14,99€"}; – vance
ラベルには「var text =((Label)sender).Text; –