public void GetData(Action<DataItem, Exception> callback) { // Use this to connect to the actual data service var item = new DataItem("Welcome to MVVM Light"); callback(item, null); }
public void GetData(Action<DataItem, Exception> callback) { // Use this to create design time data var item = new DataItem("Welcome to MVVM Light [design]"); var province = new DataItem().ProvinceItem(); callback(item, null); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(IDataService dataService) { _dataService = dataService; _dataService.GetData( (item, error) => { if (error != null) { // Report error here return; } WelcomeTitle = item.Title; Province = new DataItem().ProvinceItem(); GetCity = new RelayCommand<BaseInfo>((x) => ExecuteGetCity(x)); GetCityNext = new RelayCommand<BaseInfo>((x) => ExecuteGetCityNext(x)); ShowMessage = new RelayCommand<string>((x) => ExecuteShowMessage(x)); }); }
private object ExecuteGetCityNext(BaseInfo baseinfo) { if (baseinfo != null) { b = baseinfo; CityNext = new DataItem().CityNextItem(baseinfo.Id); } return null; }
private object ExecuteGetCity(BaseInfo baseinfo) { if (baseinfo != null) { a = baseinfo; City = new DataItem().CityItem(baseinfo.Name); } return null; }