[英]Xamarin.Forms FormsGallery MasterDetailDemoPage handle click event on generated page
I am trying to learn Xamarin.Forms, and while there are a lot of samples available, not many are commented. 我正在尝试学习Xamarin.Forms,尽管有很多可用的示例,但评论很少。 I would like to use either the FormsGallery MasterDetailDemoPage (found here https://github.com/xamarin/xamarin-forms-samples/blob/master/FormsGallery/FormsGallery/FormsGallery/MasterDetailPageDemoPage.cs ) or the CarouselPage (found here https://github.com/xamarin/xamarin-forms-samples/blob/master/FormsGallery/FormsGallery/FormsGallery/CarouselPageDemoPage.cs ) but i need to be able to handle click events on the pages that are generated.
我想使用FormsGallery MasterDetailDemoPage(在这里https://github.com/xamarin/xamarin-forms-samples/blob/master/FormsGallery/FormsGallery/FormsGallery/MasterDetailPageDemoPage.cs )或CarouselPage(在这里https: //github.com/xamarin/xamarin-forms-samples/blob/master/FormsGallery/FormsGallery/FormsGallery/CarouselPageDemoPage.cs ),但我需要能够处理所生成页面上的点击事件。
The NamedColorPage (found here https://github.com/xamarin/xamarin-forms-samples/blob/master/FormsGallery/FormsGallery/FormsGallery/NamedColorPage.cs)n is used in both of those examples. 在这两个示例中都使用了NamedColorPage(位于https://github.com/xamarin/xamarin-forms-samples/blob/master/FormsGallery/FormsGallery/FormsGallery/NamedColorPage.cs )。
I have no problem generating the pages but how do I handle click events on the generated pages. 生成页面没有问题,但是如何处理生成的页面上的单击事件。
For example, if the NamedColor object had another property called Descriptions that was List, and I want to click a button on the NamedColorPage that takes me to another page that shows the description/s how would I do that? 例如,如果NamedColor对象具有另一个名为Descriptions的属性,即List,并且我想单击NamedColorPage上的一个按钮,该按钮将我带到另一个显示该描述的页面,我该怎么做?
Button colourDescription = new Button
{
Text = "Description
};
colourDescription.Clicked += (sender, e) =>
{
//open page showing description here
}
I presume it is something to do with SetBinding or BindingContext, but there is very limited documentation on any of this, and none aimed at a complete newbie. 我认为这与SetBinding或BindingContext有关,但是关于这方面的文档非常有限,而且没有针对完整的新手的文档。
Thanks in advance 提前致谢
Worked it out 解决了
Color col = (Color)BindingContext;
then 然后
List<string> descr = col.Description;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.