0
我一直在嘗試使用複合應用程序庫(Prism),並且我已經設置了一個非常標準的模式,我已經遵循微軟的教程。基本上,視圖被注入該區域。視圖是動態構建的,以編程方式添加控件等等。重新綁定控件使用Silverlight中的PRISM模式
我有一個命令被觸發,並在回發上我想重新綁定當前視圖上的控件,而不是完全重新渲染所有控件。
所以我試圖更新模型更新版本希望這將強制重新控制。這是行不通的。不知道我應該採取什麼辦法,因爲我是棱鏡新手...
任何想法?
訂閱的事件來處理回傳
IEventAggregator aggregator = this.Container.Resolve<IEventAggregator>();
aggregator.GetEvent<DataInstanceLoadedEvent>().Subscribe(this.OnDataInstanceUpdated);
我想通了如何根據微軟的建議模式重新綁定事件
public void OnDataInstanceUpdated(DataInstance updatedInstance)
{
if(this.View.Model != null){
// We need to rebind here
IRegion region = this.LocateRegion(this.View); // gets the region....
this.View.Model.CurrentDataInstance = updatedInstance; // update the model instance
}
else{
// Render all controls over again since view.model is null ...
}
}