【发布时间】:2017-05-24 10:05:39
【问题描述】:
我想知道通过点击手势从堆栈布局中获取不同标签的最佳方法是什么。我的 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);
【问题讨论】:
标签: c# xaml xamarin xamarin.forms