我在同一个应用程序中的不同列表上工作的完全相同(就像,我已经将它们分开寻找拼写错误)。有谁知道为什么我的列表项属性不会绑定?
ViewModel - 这似乎工作正常。我得到了正确的行数,我可以在ItemSelected命令中看到这些ItemViewModels。因此,下面的块似乎处于正常工作状态:
public ObservableCollection<ItemViewModel> Items
{
get { return _items; }
set
{
_items= value;
RaisePropertyChanged(() => Items);
}
}
<namespace.MyListView
android:id="@+id/my_list"
android:layout_below="@+id/toolbar_title"
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
local:MvxItemTemplate="@layout/my_item_rowlayout"
local:MvxBind="ItemsSource Items; ItemClick ItemSelectedCommand;" />
ItemViewModel - 我可以在表的ItemSelected命令中看到这些,但没有任何属性会绑定到布局。
public string Path
{
get { return _path; }
set
{
_path = value;
RaisePropertyChanged(() => Path);
}
}
public ItemViewModel()
{
Path = "some value";
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<TextView
android:id="@+id/item_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:textColor="@android:color/black"
tools:text="test text"
android:singleLine="true"
android:textStyle="normal"
local:MvxBind="Text Path" />
</LinearLayout>
在调试MyListView时,我可以使用GetChildAt来观察如下所示的视图:
base = {MvvmCross.Binding.Droid.Views.MvxBaseListItemView}
+ base {Android.Widget.FrameLayout} Android.Widget.FrameLayout
- BindingContext {MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext} MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext
- DataContext {Namespace.ItemViewModel} Namespace.ItemViewModel
我所有的财产都在那里。
的ListView:
[Android.Runtime.Preserve(AllMembers = true)]
public class MyListView: MvxListView
{
public MyListView(Context context, IAttributeSet attrs)
: base(context, attrs)
{
}
}
从输出:
MvxBind:Error: 20.30 Problem parsing binding MvxException: Cannot terminate binding expression during option Path in Text Path
at MvvmCross.Binding.Parse.Binding.MvxBindingParser.ParseEquals (System.String block) [0x00008] in D:\git\MvvmCross\MvvmCross\Core\Binding\Parse\Binding\MvxBindingParser.cs:80
at MvvmCross.Binding.Parse.Binding.Swiss.MvxSwissBindingParser.ParseNextBindingDescriptionOptionInto (MvvmCross.Binding.Parse.Binding.MvxSerializableBindingDescription description) [0x00091] in D:\git\MvvmCross\MvvmCross\Core\Binding\Parse\Binding\Swiss\MvxSwissBindingParser.cs:39
at MvvmCross.Binding.Parse.Binding.Tibet.MvxTibetBindingParser.ParseNextBindingDescriptionOptionInto (MvvmCross.Binding.Parse.Binding.MvxSerializableBindingDescription description) [0x0002e] in D:\git\MvvmCross\MvvmCross\Core\Binding\Parse\Binding\Tibet\MvxTibetBindingParser.cs:49
at MvvmCross.Binding.Parse.Binding.Swiss.MvxSwissBindingParser.ParseBindingDescription (MvvmCross.Binding.Parse.Binding.Swiss.MvxSwissBindingParser+ParentIsLookingForComma parentIsLookingForComma) [0x0000c] in D:\git\MvvmCross\MvvmCross\Core\Binding\Parse\Binding\Swiss\MvxSwissBindingParser.cs:195
at MvvmCross.Binding.Parse.Binding.Swiss.MvxSwissBindingParser.ParseBindingDescription () [0x00000] in D:\git\MvvmCross\MvvmCross\Core\Binding\Parse\Binding\Swiss\MvxSwissBindingParser.cs:178
at MvvmCross.Binding.Parse.Binding.MvxBindingParser.ParseTargetPropertyNameAndDescription () [0x0000c] in D:\git\MvvmCross\MvvmCross\Core\Binding\Parse\Binding\MvxBindingParser.cs:73
at MvvmCross.Binding.Parse.Binding.MvxBindingParser.TryParseBindingSpecification (System.String text, MvvmCross.Binding.Parse.Binding.MvxSerializableBindingSpecification& requestedBindings) [0x00015] in D:\git\MvvmCross\MvvmCross\Core\Binding\Parse\Binding\MvxBindingParser.cs:52
答案 0 :(得分:1)
在获得提示查看输出日志后,我发现了一个异常,经过一些搜索后,似乎在尝试使用保留关键字时发生了异常。 &#34;路径&#34;保留,更改属性名称解决了问题。
查看输出日志是关键......