gpt4 book ai didi

c# - 如何从条目中获取文本

转载 作者:太空狗 更新时间:2023-10-29 21:26:14 27 4
gpt4 key购买 nike

我创建一个条目使用

 <Entry Placeholder="Reply..."/>

它在 ListView > ItemTemplate > DataTemplate > ViewCell 中

问题是我需要一种方法,一旦用户单击该 ViewCell 中的提交按钮,它就会获取该单元格中条目的文本。我正在使用 Binding 来设置值,所以我不知道如何获取文本。

最佳答案

当你处理按钮的点击事件时,假设你正在使用一个事件处理程序来监听Clicked事件,你可以得到按钮的BindingContext(应该对整个 ViewCell 也是相同的 BindingContext

像这样:

public void OnButtonClicked(object sender, EventArgs e)
{
// Assuming the List bound to the ListView contains "MyObject" objects,
// for example List<MyObject>:

var myObjectBoundToViewCell = (MyObject)((Button)sender).BindingContext;

// and now use myObjectBoundToViewCell to get the text that is bound from the Entry
}

关于c# - 如何从条目中获取文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49081512/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com