【发布时间】:2018-02-22 06:44:03
【问题描述】:
我有listview 有两个动态操纵的视图label 和button,我正在尝试访问按钮单击以转到按钮单击时的详细信息页面。
下面是我的自定义ViewCell
protected override async void OnAppearing()
{
listClass.ItemsSource = list;
listClass.ItemTemplate = new DataTemplate(typeof(ItemTemplateViewCell ));
}
public class ItemTemplateViewCell : ViewCell
{
Label NameLbl = new Label();
StackLayout sLayout = new StackLayout ();
Button btnViewcell = new Button {Text = "Show class details"};
public ItemTemplateViewCell()
{
NameLbl.SetBinding(Label.TextProperty, "Name");
sLayout.Children.Add(NameLbl);
btnViewcell.Clicked += (s, e) =>
{
// Navigation.PushAsync(new Home()); //I can not using this line
// does not exist in the current context, why cant i navigate to
// another page from inside datatemplate in List view
};
sLayout.Children.Add(btnViewcell);
this.View = sLayout;
}
}
【问题讨论】:
-
我希望
Navigation.PushAsync(...后面的注释在您实际代码中的一行?请把它放在一行然后在这里,因为这确实在编码方面有很大的不同
标签: c# xamarin.forms cross-platform portable-class-library