void UCLanguagesDescription_Loaded(object sender, RoutedEventArgs e) { //LanguageOptions=ConfigurationManager facade = new Facade(CPApplication.Current.CurrentPage); //获取业务对象类型 CodeNamePairHelper.GetList(ConstValue.DomainName_Common, ConstValue.Key_BizObjectType, (o, p) => { codeNamePairList = p.Result; CodeNamePair CodeName = codeNamePairList.Where(s => s.Code == bizObjectType).SingleOrDefault(); vm.BizObjectType = CodeName.Code; if (vm.BizObjectType == "Product") { vm.BizObjectId = bizObjectNo; } if (vm.BizObjectType == "Merchant") { vm.BizObjectSysNo = int.Parse(bizObjectNo); } vm.ShowBizObjectTypeName = CodeName.Name; List <KeyValuePair <string, string> > languageList = GetLanguageList(); facade.LoadBizObjectLanguageDescList(vm.BizObjectType, vm.BizObjectSysNo, vm.BizObjectId, (obj, args) => { listvm = args.Result; if (listvm != null && listvm.Count > 0) { for (int i = 0; i < listvm.Count; i++) { listvm[i].BizObjectSysNo = vm.BizObjectSysNo; listvm[i].BizObjectType = vm.BizObjectType; listvm[i].BizObjectId = vm.BizObjectId; listvm[i].ShowLanguageTypeName = languageList.Where(s => s.Key == listvm[i].LanguageCode).SingleOrDefault().Value; UCLanguageDescripttionSetting uc = new UCLanguageDescripttionSetting(); uc.DataContext = listvm[i]; Containner.Children.Add(uc); languageList.Remove(languageList.Where(k => k.Key == listvm[i].LanguageCode).SingleOrDefault()); } } if (languageList != null && languageList.Count > 0) { for (int i = 0; i < languageList.Count; i++) { if (listvm == null || !listvm.Any(l => l.LanguageCode == languageList[i].Key)) { BizObjecLanguageDescVM view = new BizObjecLanguageDescVM(); view.BizObjectSysNo = vm.BizObjectSysNo; view.BizObjectType = vm.BizObjectType; view.BizObjectId = vm.BizObjectId; view.LanguageCode = languageList[i].Key; view.ShowLanguageTypeName = languageList[i].Value; UCLanguageDescripttionSetting uc = new UCLanguageDescripttionSetting(); uc.DataContext = view; Containner.Children.Add(uc); } } } }); this.DataContext = vm; }); this.Loaded -= UCLanguagesDescription_Loaded; }
public UCLanguageDescripttionSetting() { facade = new Facade(CPApplication.Current.CurrentPage); InitializeComponent(); this.Loaded += new RoutedEventHandler(UCLanguageDescripttionSetting_Loaded); }