【发布时间】:2012-10-15 16:07:36
【问题描述】:
当我在 Tutorial.Core 中更改 MainMenuViewModel 以使用这样的字典时:
`公共词典项目{get;放; } 公共 ICommand ShowItemCommand { 得到 { 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>
提前感谢您的帮助。
【问题讨论】:
标签: c# windows-phone-7 xamarin.ios xamarin.android mvvmcross