我尝试将MvxListView的选定项绑定到我的属性。这是我的布局:
[ImplementPropertyChanged]
public class SelectCategoryListViewModel : AbstractCategoryListViewModel
{
/// <summary>
/// Creates an CategoryListViewModel for the usage of providing a category selection.
/// </summary>
/// <param name="categoryRepository">An instance of <see cref="IRepository{T}" /> of type category.</param>
/// <param name="dialogService">An instance of <see cref="IDialogService" /></param>
public SelectCategoryListViewModel(IRepository<Category> categoryRepository,
IDialogService dialogService) : base(categoryRepository, dialogService)
{}
public Category SelectedCategory { get; set; }
public MvxCommand DoneCommand => new MvxCommand(Done);
public MvxCommand CancelCommand => new MvxCommand(Cancel);
private void Done()
{
MessageHub.Publish(new CategorySelectedMessage(this, SelectedCategory));
Close(this);
}
private void Cancel()
{
Close(this);
}
}
此处的ItemSource已正确绑定。
视图模型:
public class SelectCategoryListActivity : MvxFragmentCompatActivity<SelectCategoryListViewModel>
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.fragment_category_list);
SetSupportActionBar(FindViewById<Toolbar>(Resource.Id.toolbar));
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
}
...
不是通过Fody完成通知PropertyChanged,而且类别在父虚拟机中。
<ul class="footerNav footnav1">
<?php $parents = table_fetch_rows('page', 'status = 1 AND footer_nav = 1 AND parent_id < 0', 'position ASC'); ?>
<?php if(count($parents) > 0): ?>
<?php foreach($parents as $key => $parent): ?>
<li><a href="<?php echo getRewriteUrl('page', $parent['id']); ?>"><?php echo $parent['menu_title']; ?></a></li>
<?php endforeach; ?>
<?php endif; ?>
</ul><!-- footerNav -->
我得到的警告是:
[0:] MvxBind:警告:5.11无法为SelectedCategory绑定SelectedItem创建目标绑定
想法?
答案 0 :(得分:3)
我遇到了类似的问题,SelectedItem
绑定失败了。解决方案是将Mvx更新到4.1.6版。原因是您需要注册MvxAppCompatSetupHelper.FillTargetFactories
,而4.1.6现在已自动完成。
或者,您可以通过覆盖FillTargetFactories
:
protected override void FillTargetFactories(IMvxTargetBindingFactoryRegistry registry)
{
MvxAppCompatSetupHelper.FillTargetFactories(registry);
base.FillTargetFactories(registry);
}