无法在 xamarin 中编辑框架内的条目
Not able to edit the entry inside the frame in 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>
这里每一帧都是一个列表项。
问题出在我有一个输入框的列表项中。但我无法编辑文本。我尝试了 google 中给出的所有可能的解决方案,但该条目仍然不可编辑。我请求任何人以 xamarin 形式帮助我解决这个问题。
谢谢
正如杰森所说,xaml 无效。先把stacklayout放在frame里面。
Xaml:
<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; }
}
现在可以编辑该条目。
我正在使用 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>
这里每一帧都是一个列表项。 问题出在我有一个输入框的列表项中。但我无法编辑文本。我尝试了 google 中给出的所有可能的解决方案,但该条目仍然不可编辑。我请求任何人以 xamarin 形式帮助我解决这个问题。
谢谢
正如杰森所说,xaml 无效。先把stacklayout放在frame里面。
Xaml:
<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; }
}
现在可以编辑该条目。