【发布时间】:2018-08-21 12:02:51
【问题描述】:
我需要更改以下方法:
public static IList<SomeItem> GetProjects() {
List<SomeItem> projects = new List<SomeItem>();
string result = Task.Run(() => TestMethodAsync("getProjects",GetApiKeyAsync())).GetAwaiter().GetResult();
MyObject resultparsed = new JavaScriptSerializer().Deserialize<MyObject>(result);
foreach (SomeItem item in resultparsed.result.items)
{
projects.Add(item);
}
return projects;
}
项目将自动添加到ComboBox:
这是来自 XAML:
<ComboBox ItemsSource="{Binding Path=ProjectList}" IsSynchronizedWithCurrentItem="True" />
这里我正在尝试修改上面的代码 C#:
public List<string> ProjectList { get; internal set; }
public static IList<SomeItem> GetProjects()
{
ProjectList = new List<string>;//???
string result = Task.Run(() => TestMethodAsync("getProjects",GetApiKeyAsync())).GetAwaiter().GetResult();
MyObject resultparsed = new JavaScriptSerializer().Deserialize<MyObject>(result);
foreach (SomeItem item in resultparsed.result.items)
{
ProjectList.Add(item);//??
}
}
【问题讨论】:
标签: c# wpf list data-binding combobox