C# 获取对特定WPF列表框的引用
我试图通过编程方式根据设置为列表框名称的字符串获取对特定WPF列表框的引用。我正试图完成这段代码:C# 获取对特定WPF列表框的引用,c#,listbox,C#,Listbox,我试图通过编程方式根据设置为列表框名称的字符串获取对特定WPF列表框的引用。我正试图完成这段代码: StackTrace st = new StackTrace(); string cmn = (st.GetFrame(0).GetMethod().ToString().Remove(0, 5)).Remove(4, 3); stringArray = processMethodName(cmn); populateLists(stringArray[0], stringArray[1], ls
StackTrace st = new StackTrace();
string cmn = (st.GetFrame(0).GetMethod().ToString().Remove(0, 5)).Remove(4, 3);
stringArray = processMethodName(cmn);
populateLists(stringArray[0], stringArray[1], lst_Ingredients);
我的'processMethodName'函数为stringArray[2]返回一个值,该值设置为'lst_Components',但我不知道如何实现它。有什么建议吗?终于找到了答案。令人沮丧的是,在列表框中引用对象的帖子/链接太多。总之,我需要一行代码:
populateLists(stringArray[0], stringArray[1], (ListBox)FindName(stringArray[2]));
你在说什么列表框?WinForms列表框、ASP.NET或其他完全不同的东西?