【问题标题】:Xamarin.Forms FormsGallery MasterDetailDemoPage handle click event on generated pageXamarin.Forms FormsGallery MasterDetailDemoPage 处理生成页面上的点击事件
【发布时间】:2014-11-05 02:02:24
【问题描述】:

我正在尝试学习 Xamarin.Forms,虽然有很多示例可用,但没有多少示例可用。 我想使用 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),但我需要能够处理生成的页面上的点击事件。

NamedColorPage(在此处找到https://github.com/xamarin/xamarin-forms-samples/blob/master/FormsGallery/FormsGallery/FormsGallery/NamedColorPage.cs)n)用于这两个示例。

生成页面没有问题,但是如何处理生成页面上的点击事件。

例如,如果 NamedColor 对象有另一个名为 Descriptions 的 List 属性,我想单击 NamedColorPage 上的一个按钮,该按钮将我带到另一个显示描述的页面,我该怎么做?

Button colourDescription = new Button
{
     Text = "Description
};

colourDescription.Clicked += (sender, e) =>
{

    //open page showing description here

}

我认为这与 SetBinding 或 BindingContext 有关,但关于这方面的文档非常有限,而且没有一个针对完整的新手。

提前致谢

【问题讨论】:

    标签: c# binding xamarin xamarin.forms


    【解决方案1】:

    解决了

    Color col = (Color)BindingContext;
    

    然后

    List<string> descr = col.Description;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 2015-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多