Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 获取对特定WPF列表框的引用_C#_Listbox - Fatal编程技术网

C# 获取对特定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

我试图通过编程方式根据设置为列表框名称的字符串获取对特定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], lst_Ingredients);

我的'processMethodName'函数为stringArray[2]返回一个值,该值设置为'lst_Components',但我不知道如何实现它。有什么建议吗?

终于找到了答案。令人沮丧的是,在列表框中引用对象的帖子/链接太多。总之,我需要一行代码:

populateLists(stringArray[0], stringArray[1], (ListBox)FindName(stringArray[2]));

你在说什么列表框?WinForms列表框、ASP.NET或其他完全不同的东西?