gpt4 book ai didi

c# - Xamarin Android Spinner 绑定(bind)选择不起作用

转载 作者:行者123 更新时间:2023-11-30 01:52:19 24 4
gpt4 key购买 nike

我能够将数组 _limitQuickPosts 绑定(bind)到我的微调器。但是我很难弄清楚如何将 Selected 绑定(bind)到我的 _selectedLimitQuickPosts。无论我做什么,我都无法将 Selected 值设置为“显示最近 200 篇帖子”。

核心 View 模型:

private string[] _limitQuickPosts = new string[4]
{
"Show last 25 Posts",
"Show last 50 Posts",
"Show last 100 Posts",
"Show last 200 Posts"
};
public string[] LimitQuickPosts
{
get { return _limitQuickPosts; }
set { _limitQuickPosts = value; RaisePropertyChanged(() => LimitQuickPosts); }
}

private string _selectedLimitQuickPosts = "Show last 200 Posts";
public string SelectedLimitQuickPosts
{
get { return _selectedLimitQuickPosts; }
set { _selectedLimitQuickPosts = value; RaisePropertyChanged(() => SelectedLimitQuickPosts); }
}

机器人布局:

<MvxSpinner
android:layout_width="210dp"
android:layout_height="wrap_content"
android:textSize="40dp"
android:id="@+id/limitSelect"
android:minWidth="50dp"
android:layout_marginLeft="10dp" />

机器人 View :

...
var limitSelect = fragView.FindViewById<MvxSpinner>(Resource.Id.limitSelect);
...
...
set.Bind(limitSelect).For(x => x.ItemsSource).To(vm => vm.LimitQuickPosts);
set.Bind(limitSelect).For(x => x.Selected).To(vm => vm.SelectedLimitQuickPosts);

虽然它适本地将 LimitQuickPosts 绑定(bind)到 Spinner,并且我可以看到所有可用的选择,但我仍然摸不着头脑,想知道 Selected 为何没有绑定(bind)以及我必须做些什么才能正确绑定(bind)?

最佳答案

查看本期:Issue binding to MVXSpinner after upgrading to Mvvmcross v4.0.0-beta3

您必须从 Setup.cs 的 FillTargetFactories() 调用 MvxAppCompatSetupHelper.FillTargetFactories

关于c# - Xamarin Android Spinner 绑定(bind)选择不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32833347/

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