gpt4 book ai didi

c# - Mvvmcross TableView 绑定(bind)触发器两次

转载 作者:行者123 更新时间:2023-11-29 21:36:06 27 4
gpt4 key购买 nike

在使用 Mvvmcross 和 Monodroid 创建 Android 应用程序时,我有一个包含表格的 Activity 。当按下表格的一个元素时,ItemClick 方法的绑定(bind)被调用两次。这是有可能的,因为它会导致 View 的其他元素出现问题。

表格 View .axml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="..."
android:id="@+id/TableView_Container"
style="@style/TableView_SearchContainer">
<Mvx.MvxListview
android:id="@+id/TableView_List"
style="@style/TableView_List"
local:MvxBind="ItemsSource StackInfos;ItemClick OnClick;"
local:MvxItemTemplate="@layout/list_item" />
</RelativeLayout>

OnClick 方法在使用日志记录测试时被调用了两次。

这是一个已知的 Mvvmcross 问题吗?有没有办法进一步追踪绑定(bind)?

是否有已知的修复方法?

最佳答案

The OnClick method is called twice as tested with logging.

我刚刚在 https://github.com/slodge/MvvmCross-Tutorials/tree/master/ApiExamples 的 ListView 上测试了这个

我修改了 View 模型:

public class ListViewModel : BaseListTestViewModel
{
private int i = 0;

public ICommand HelloCommand
{
get { return new MvxCommand(() => Mvx.Trace("Hello " + ++i));}
}
}

和 View :

  <MvxListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
local:MvxBind="ItemsSource Items;ItemClick HelloCommand"
/>

查看跟踪和 Android 调试日志,每次点击只有一次调用 - i 每次点击都会增加一次。


Is there a way I can trace the binding further?

您可以使用 MvxBindingTrace.TraceBindingLevel = MvxTraceLevel.Diagnostic; 增加绑定(bind)日志记录的详细程度 - 但我怀疑这能告诉您很多。

您可以自己构建 MvvmCross 源代码 - 或者从 https://github.com/slodge/MvvmCross-Binaries/ 获取调试程序集和 pdb 文件

您可以从 https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross.Binding.Droid/Views/MvxListView.cs 复制 MvxListView 源代码进入您的应用程序中的一个新类 - 比如 MyListView - 然后在您的应用程序中的该 ListView 上使用“正常调试技术”。

关于c# - Mvvmcross TableView 绑定(bind)触发器两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18412537/

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