我正在开发一个跨平台的应用程序,在android中启动它.我找到了你的MVVMCross项目,我正试图进入它.现在我对它完全陌生,不知道如何将我的WebService-Results绑定到我的ListView.这里有一些XAML作为示例,我正在尝试它:
xmlns:mobsales="http://schemas.android.com/apk/res/MobSales.DroidUI"
...
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
mobsales:MvxItemTemplate="@layout/listitem_customer"
mobsales:MvxBind="{'ItemSource':{'Path':'Customer'}}" />
...
Run Code Online (Sandbox Code Playgroud)
看起来像这样
<cirrious.mvvmcross.binding.android.views.MvxBindableListView
android:id="@+id/autocomplete"
android:layout_below="@id/txtfield"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
mobsales:MvxItemTemplate="@layout/listitem_customer"
mobsales:MvxBind="{'ItemSource':{'Path':'Customers'}}" />
Run Code Online (Sandbox Code Playgroud)
当我徘徊最后两行时,工具提示表示属性未声明.我真的不知道你是怎么做到的.你能给我一些建议吗?我想我必须在我的UI项目的值中编写一些xml,对吧?
另一个问题:我怎么能使用AutoCompleteTextViews?我必须首先编写自己的MvXBindables吗?有什么建议?:-)
是否有可能在视图模型中有一个构造函数,它初始化数据服务?(不要误解我的意思,我的数据服务正在访问数据存储的Web服务)这样的事情(问我因为我得到ViewLoader抛出的异常"无法加载ViewModel ......"而且它没有显示整个例外...):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using Cirrious.MvvmCross.ViewModels;
using Cirrious.MvvmCross.Commands;
using MobSales.Logic.DataService;
using MobSales.Logic.Base;
using MobSales.Logic.Model;
namespace MobSales.Logic.ViewModels
{
public class CustomersViewModel:MvxViewModel
{
ICustomerService custService;
public CustomersViewModel(ICustomerService custService)
{
this.custService = custService;
if (custService != null)
{
custService.LoadCustomerCompleted += new EventHandler<CustomerLoadedEventArgs>(custService_LoadCustomerCompleted);
}
loadCustomerCommand = new MvxRelayCommand(LoadCustomer);
loadCustomerCommand.Execute();
}
private ObservableCollection<Customer> customers;
public ObservableCollection<Customer> Customers
{
get { return customers; }
set
{
customers = value;
FirePropertyChanged("Customers");
}
}
private CustomerViewModel customer;
public CustomerViewModel Customer …Run Code Online (Sandbox Code Playgroud)