首页 > 解决方案 > 从 Label-ScrollView -Xamarin Forms 中获取价值

问题描述

我正在开发一个 Xamarin 表单项目。我试图在 Xaml 文件中获取 FlexView 内的 Label 的绑定值以比较字符串,以便它将用户导航到正确的页面,但始终显示 null 并且无法检索该值。

这是 XAML XAML SS

public MainPage()
{
    InitializeComponent();
    BookClasses = new List<BookClass>()
    {
        new BookClass {BookClassification = "New Release", IconUrl = "new2.png"},
        new BookClass {BookClassification = "Top Reading",IconUrl = "top.png"},
        new BookClass {BookClassification = "Editor Choice",IconUrl = "editorchoice.png"},
        new BookClass {BookClassification = "Recommended",IconUrl = "recommed.png"},
        new BookClass {BookClassification = "Geners",IconUrl = "gener.png"}
    };

    BindingContext = this;
}

public IList<BookClass> BookClasses { get; set; }

private void TapGestureRecognizer_OnTapped(object sender, EventArgs e)
{

    var usrselectioncat = (BookClass) ((ListView) sender).SelectedItem;
    string catname = usrselectioncat.BookClassification;
    string catimage = usrselectioncat.IconUrl;
    if (catname == "New Release")
    {
        Navigation.PushAsync(new NewRelease());
    }
}

标签: c#xamarin.forms

解决方案


推荐阅读