当我在 Tutorial.Core 中更改 MainMenuViewModel 以使用这样的字典时:
`公共字典项目{得到; 放; } public ICommand ShowItemCommand { get { return new MvxRelayCommand>((type) => DoShowItem(type.Value)); } }
public void DoShowItem(Type itemType)
{
this.RequestNavigate(itemType);
}
public MainMenuViewModel()
{
Items = new Dictionary<string, Type>()
{
{"SimpleTextProperty", typeof(Lessons.SimpleTextPropertyViewModel)},
{"PullToRefresh", typeof(Lessons.PullToRefreshViewModel)},
{"Tip", typeof(Lessons.TipViewModel)},
{"Composite",typeof(Lessons.CompositeViewModel)},
{"Location",typeof(Lessons.LocationViewModel)}
};
}`
该示例在 wp7 中按预期工作,但是对于 monodroid 我收到一个错误::"MvxBind:Error: 2,71 Problem seen during binding execution for from Items to ItemsSource - 问题 ArgumentException: failed to convert parameters" 因为我认为 KeyValuePair Key属性导致问题:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/Tutorial.UI.Droid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="View Model:"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
local:MvxBind="{'Text':{'Path':'Key'}}"
/>
</LinearLayout>
在此先感谢您的帮助。