我在XAML中具有以下val jsonObj: JsonObject = JsonParser().parse(body).asJsonObject
val astronomy = jsonObj
.getAsJsonObject("query")
.getAsJsonObject("results")
.getAsJsonObject("channel")
.getAsJsonObject("astronomy")
runOnUiThread {
toast("this is running from UiThread ${astronomy.get("sunrise").asString}")
}
:
INSERT INTO [New ZSPWAR Prime] (Payer, AI, Bill_doc,
Sqwak, Site, Plnt, Billing_Dt, ProfitCntr, Customer,
Equipment, Issued_Material, Material_Description, SLoc,
Serial_No, ItCC, Mtrl_Grp, Manuf_No, Manuf_Name, RTN,
Warranty, PPC, SVO_No, Ref_No, Notification_Subject,
AC_C, Corrective_Action, SB_Data, AC_R, Corr_Action_R,
SaleDebCre, Sales_Ord, SO_Date, SU, Returned_Material,
Returned_SNR, [Reason for Rejection], SLCo, Canel_Doc,
Can_Doc_Dt, Tail, ItCa, Sold_to, Sold_to_Name,
Customer_PO_No, [User], Comp_Date, OB_Del_NO, OB_Del_DT,
Ret_Delv, Rt_SO_It, Ret_Date, Ret_EQUI, Ret_Note,
NoteCR_DT, NoteCM_DT, Ret_Note_DESC, WACD,
Wty_Prog_Code_Desc, PO_NO, PO_DT, PO_PI, VR_Amount,
INV_PT_DT, ZZ07, Freight_Amt, [ME23N PO_Owner], VDCD,
Ven_Den_Code_Desc, DISP, [Disp code Descr], PRI, HVNE,
[Approve By], [MM Vendor Number], [Sourcing Vendor Number],
[Sourcing Vendor Name], [Vendor Contract], [FFF Class],
[Ref Contract], [Company Code], [BUSAC TYPE],
[Warr Typ], [Aircraft Material], [Aircraft Serial Number],
[Aircraft Program], [GL Date], [Obj Type], [ID Number],
[MD04 Purchasing Group], [MD04 PurG Name], [RO Number],
[RO Creation Date], [RO Contact Name], [RO Vendor Code],
[RO Vendor Name], [ODC Amount], [Issue_New/Rotable],
Issue_Core, [Recovery_New/Rotable], Recovery_Core,
Labor_Hours, Rate, Labor_Cost, Mtrl_Qty_Billed,
Mtrl_ea_Cost, Mtrl_ttl_Cost, Total_Cost, MAUC_STD,
Core_cost, Cat_Price, Discount, [% Discount],
[ODC Freight], [Repair Cost], [Material Burden],
[% Material Burden], [Rotable Depreciation], [% Core Dep],
[Net Spend], Margin, Item_Cost, [Total Material Burden],
[Total Rotables Dep], SVO_Direct_Labor, SVO_Labor_OH)
SELECT [New ZSPWAR Merge].Payer, [New ZSPWAR Merge].AI,
[New ZSPWAR Merge].Bill_doc, [New ZSPWAR Merge].Sqwak,
[New ZSPWAR Merge].Site, [New ZSPWAR Merge].Plnt,
[New ZSPWAR Merge].Billing_Dt, [New ZSPWAR Merge].ProfitCntr,
[New ZSPWAR Merge].Customer, [New ZSPWAR Merge].Equipment,
[New ZSPWAR Merge].Issued_Material, [New ZSPWAR Merge].Material_Description,
[New ZSPWAR Merge].SLoc, [New ZSPWAR Merge].Serial_No, [New ZSPWAR Merge].ItCC,
[New ZSPWAR Merge].Mtrl_Grp, [New ZSPWAR Merge].Manuf_No, [New ZSPWAR Merge].Manuf_Name,
[New ZSPWAR Merge].RTN, [New ZSPWAR Merge].Warranty, [New ZSPWAR Merge].PPC,
[New ZSPWAR Merge].SVO_No, [New ZSPWAR Merge].Ref_No, [New ZSPWAR Merge].Notification_Subject,
[New ZSPWAR Merge].AC_C, [New ZSPWAR Merge].Corrective_Action,
[New ZSPWAR Merge].SB_Data, [New ZSPWAR Merge].AC_R,
[New ZSPWAR Merge].Corr_Action_R, [New ZSPWAR Merge].SaleDebCre,
[New ZSPWAR Merge].Sales_Ord, [New ZSPWAR Merge].SO_Date,
[New ZSPWAR Merge].SU, [New ZSPWAR Merge].Returned_Material,
[New ZSPWAR Merge].Returned_SNR, [New ZSPWAR Merge].[Reason for Rejection],
[New ZSPWAR Merge].SLCo, [New ZSPWAR Merge].Canel_Doc,
[New ZSPWAR Merge].Can_Doc_Dt, [New ZSPWAR Merge].Tail,
[New ZSPWAR Merge].ItCa, [New ZSPWAR Merge].Sold_to,
[New ZSPWAR Merge].Sold_to_Name, [New ZSPWAR Merge].Customer_PO_No,
[New ZSPWAR Merge].User, [New ZSPWAR Merge].Comp_Date,
[New ZSPWAR Merge].OB_Del_NO, [New ZSPWAR Merge].OB_Del_DT,
[New ZSPWAR Merge].Ret_Delv, [New ZSPWAR Merge].Rt_SO_It,
[New ZSPWAR Merge].Ret_Date, [New ZSPWAR Merge].Ret_EQUI,
[New ZSPWAR Merge].Ret_Note, [New ZSPWAR Merge].NoteCR_DT,
[New ZSPWAR Merge].NoteCM_DT, [New ZSPWAR Merge].Ret_Note_DESC,
[New ZSPWAR Merge].WACD, [New ZSPWAR Merge].Wty_Prog_Code_Desc,
[New ZSPWAR Merge].PO_NO, [New ZSPWAR Merge].PO_DT,
[New ZSPWAR Merge].PO_PI, [New ZSPWAR Merge].VR_Amount,
[New ZSPWAR Merge].INV_PT_DT, [New ZSPWAR Merge].ZZ07,
[New ZSPWAR Merge].Freight_Amt, [New ZSPWAR Merge].[ME23N PO_Owner],
[New ZSPWAR Merge].VDCD, [New ZSPWAR Merge].Ven_Den_Code_Desc,
[New ZSPWAR Merge].DISP, [New ZSPWAR Merge].[Disp code Descr],
[New ZSPWAR Merge].PRI, [New ZSPWAR Merge].HVNE, [New ZSPWAR Merge].[Approve By],
[New ZSPWAR Merge].[MM Vendor Number], [New ZSPWAR Merge].[Sourcing Vendor Number],
[New ZSPWAR Merge].[Sourcing Vendor Name], [New ZSPWAR Merge].[Vendor Contract], [New ZSPWAR Merge].[FFF Class],
[New ZSPWAR Merge].[Ref Contract], [New ZSPWAR Merge].[Company Code],
[New ZSPWAR Merge].[BUSAC TYPE], [New ZSPWAR Merge].[Warr Typ],
[New ZSPWAR Merge].[Aircraft Material], [New ZSPWAR Merge].[Aircraft Serial Number],
[New ZSPWAR Merge].[Aircraft Program], [New ZSPWAR Merge].[GL Date],
[New ZSPWAR Merge].[Obj Type], [New ZSPWAR Merge].[ID Number],
[New ZSPWAR Merge].[MD04 Purchasing Group],
[New ZSPWAR Merge].[MD04 PurG Name], [New ZSPWAR Merge].[RO Number],
[New ZSPWAR Merge].[RO Creation Date], [New ZSPWAR Merge].[RO Contact Name], [New ZSPWAR Merge].[RO Vendor Code],
[New ZSPWAR Merge].[RO Vendor Name], [New ZSPWAR Merge].[ODC Amount],
[New ZSPWAR Merge].[Issue_New/Rotable], [New ZSPWAR Merge].Issue_Core,
[New ZSPWAR Merge].[Recovery_New/Rotable], [New ZSPWAR Merge].Recovery_Core,
[New ZSPWAR Merge].Labor_Hours, [New ZSPWAR Merge].Rate, [New ZSPWAR Merge].Labor_Cost,
[New ZSPWAR Merge].Mtrl_Qty_Billed, [New ZSPWAR Merge].Mtrl_ea_Cost,
[New ZSPWAR Merge].Mtrl_ttl_Cost, [New ZSPWAR Merge].Total_Cost,
[New ZSPWAR Merge].MAUC_STD, [New ZSPWAR Merge].Core_cost,
[New ZSPWAR Merge].Cat_Price, [New ZSPWAR Merge].Discount,
[New ZSPWAR Merge].[% Discount], [New ZSPWAR Merge].[ODC Freight],
[New ZSPWAR Merge].[Repair Cost], [New ZSPWAR Merge].[Material Burden],
[New ZSPWAR Merge].[% Material Burden], [New ZSPWAR Merge].[Rotable Depreciation],
[New ZSPWAR Merge].[% Core Dep], [New ZSPWAR Merge].[Net Spend],
[New ZSPWAR Merge].Margin, [New ZSPWAR Merge].Item_Cost,
[New ZSPWAR Merge].[Total Material Burden], [New ZSPWAR Merge].[Total Rotables Dep],
[New ZSPWAR Merge].SVO_Direct_Labor, [New ZSPWAR Merge].SVO_Labor_OH
FROM [New ZSPWAR Merge]
WHERE ( ( ( [New ZSPWAR Merge].Bill_doc ) NOT LIKE "1*" )
AND ( ( [New ZSPWAR Merge].ItCC ) LIKE "ZCOM" )
AND ( ( [New ZSPWAR Merge].ItCa ) NOT LIKE "ZRN*" )
)
OR ( ( ( [New ZSPWAR Merge].Bill_doc ) NOT LIKE "1*"
)
AND ( ( [New ZSPWAR Merge].ItCC ) LIKE "ZCOM" )
AND ( ( [New ZSPWAR Merge].ItCa ) NOT LIKE "I*"
) );
我需要在ComboBox
中填充一个列表:
<ComboBox Header="Cities" Width="245" SelectedItem="{Binding Cities, Mode=TwoWay}"/>
该列表由在API中运行的查询填充:
ViewModel
我需要用城市列表的内容加载组合框。我该怎么办?
答案 0 :(得分:1)
使用 x:Bind 以获得更好的性能,而不是 Binding ,您不需要双向绑定即可从后端填充数据,而无需绑定到SelectedItem,只需使用 ItemsSource 并确保使用 ObservableCollection 代替 List ,这有助于在后端列表中添加或删除项目时自动更新UI。
<ComboBox Header="Cities" Width="245" ItemsSource="{x:Bind vm.Cities}"/>
在上面的代码中,我假设 vm 是您页面的后端代码(yourPage.xaml.cs)中类型(your viewmodel)的属性
ViewModel
public ObservableCollection<City> Cities = new ObservableCollection<City>();
public async void CargarCiudades()
{
var list = await App.Repository.City.GetAsync();
foreach (var i in list)
{
this.Cities.Add(i);
}
}
答案 1 :(得分:0)
ComboBox绑定到List
如果将“城市”集合更改为ObservableCollection