Fixed issue when bindingContext is bound more than once.

This commit is contained in:
Nedyalko Nikolov
2015-04-30 13:48:52 +03:00
parent 315959a590
commit 2e4b2eacf2
10 changed files with 136 additions and 46 deletions

View File

@@ -0,0 +1,34 @@
import observableModule = require("data/observable");
import pageModule = require("ui/page");
class MainViewModel extends observableModule.Observable {
private _item: any;
constructor() {
super();
this.item = { Title: "Alabala" };
}
get item(): any {
return this._item;
}
set item(value: any) {
if (this._item !== value) {
this._item = value;
this.notifyPropertyChanged("item", value);
}
}
notifyPropertyChanged(propertyName: string, value: any) {
this.notify({ object: this, eventName: observableModule.Observable.propertyChangeEvent, propertyName: propertyName, value: value });
}
}
var viewModel = new MainViewModel();
export function pageLoaded(args: observableModule.EventData) {
var page = <pageModule.Page>args.object;
page.bindingContext = viewModel;
}