android - 无法在 xamarin 中编辑框架内的条目
问题描述
我正在使用 BindableLayout,在其中,我正在显示项目列表
<StackLayout
BindableLayout.ItemsSource="{Binding AccountsList}" Spacing="0">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Frame
Margin="0,5,0,10"
Padding="10">
<Label Text="testinnnng"/>
<Entry Text="{Binding UserText}"/>//this entry is not allowing the user to click on the UI since it is inside the list item
</Frame>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
这里每一帧都是一个列表项。问题出在列表项内,我有一个输入框。但我无法编辑文本。我尝试了谷歌给出的所有可能的解决方案,但仍然无法编辑该条目。我请求任何人以 xamarin 形式帮助我解决这个问题。
谢谢
解决方案
就像杰森说的那样,xaml 是无效的。首先将stacklayout放在框架内。
xml:
<StackLayout BindableLayout.ItemsSource="{Binding AccountsList}" Spacing="0">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Frame Margin="0,5,0,10" Padding="10">
<StackLayout>
<Label Text="testinnnng" />
<Entry Text="{Binding UserText}" />
</StackLayout>
</Frame>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
后面的代码:
public partial class Page2 : ContentPage
{
public ObservableCollection<Info> AccountsList { get; set; }
public Page2()
{
InitializeComponent();
AccountsList = new ObservableCollection<Info>()
{
new Info(){ UserText="A"},
new Info(){ UserText="B"},
new Info(){ UserText="C"},
new Info(){ UserText="D"},
};
this.BindingContext = this;
}
}
public class Info
{
public string UserText { get; set; }
}
现在可以编辑该条目。
推荐阅读
- python - Python从嵌套字典中提取正确的数据
- javascript - 使用 id 的另一个对象数组过滤 javascript 中的对象数组
- c - XGZP6859D 带 Stm32f302R8 的压力传感器
- pandas - 具有附加条件的数据透视表总和
- python - 距离矩阵 - NetworkX
- enums - 如何将字符串值与 SRL 中的枚举值进行比较
- c# - 有没有办法让用户选择他想在水晶报表上显示的组?
- python - python烧瓶代码更改未反映在使用gunicorn的应用程序中-systemd
- azure-pipelines-yaml - 如何在特定文件夹和分支上设置触发器
- python - 从 Python 将 wav 转换为 wav ulaw