c# - 从 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# - 来自多个 Foreach 的 Linq
- python - 根据条件获取链接文本和元素文本
- javascript - Vuex:从动作中调用 getter
- android - 无法解码流:java.io.FileNotFoundException BitmapFactory
- java - 导入静态 io.restassured.RestAssured.*;不工作
- arrays - Powershell foreach(列出引用的数组项命令)
- pandas - 在 Pandas 中将数据从一个数据帧移动到另一个数据帧,其中一列相同
- regex - 谷歌表格正则表达式找到最左边的交替匹配
- c# - 更新 2 Pcs 中的 datagridview
- jquery - jQuery忽略调用html()时创建的初始html元素