微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法在 xamarin 中编辑框架内的条目

如何解决无法在 xamarin 中编辑框架内的条目

我正在使用 BindableLayout 并且在其中显示一个项目列表

<StackLayout
   BindableLayout.ItemsSource="{Binding AccountsList}" Spacing="0">
      <BindableLayout.ItemTemplate>
           <DataTemplate>
               <Frame
                  Margin="0,5,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 形式帮助我解决这个问题。

谢谢

解决方法

就像 Jason 所说的,xaml 是无效的。先把stacklayout放到frame里面。

XML:

<StackLayout BindableLayout.ItemsSource="{Binding AccountsList}" Spacing="0">
        <BindableLayout.ItemTemplate>
            <DataTemplate>
                <Frame Margin="0,5,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; }
}

现在可以编辑条目。

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。