添加字符串数组组合框 [英] Adding string array to combo box

查看:123
本文介绍了添加字符串数组组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我想用从一个方法返回一个字符串数组加载一个组合框。我现在只是有这个加载一个for循环,但我想应该有客场挑战刚刚assingn字符串数组直接到组合框。 (我只是想提高我的code)

I have a combo box that I want to load with a string array that is returned from a method. I currently just have this being loaded with a for loop but I think there should be away to just assingn the string array directly to the combo box. (I'm just trying to improve my code)

我已经做了一些搜索和我见过使用datarange或数据源,但这些都不似乎工作的答案。我也试图DataContext的作为似乎是一个可能性。是否有什么我失踪或者有没有办法assing阵列的所有在一行中?

I've done some searching and I've seen answers using datarange or datasource but neither of these seem to work. I also have tried datacontext as that seemed like a possibility. Is there something I'm missing or there not a way to assing the array all in one line?

我使用C#和WPF的文件是MainWindow.xaml.cs

I am using C# WPF and the file is the MainWindow.xaml.cs

谢谢!

推荐答案

的ItemsSource 是要分配给什么。

ItemsSource is what you want to assign to.

数据源在Windows窗体时,你通常不会遇到它在WPF中,如果你想了解的 DataContexts 您需要在读了< A HREF =htt​​p://msdn.microsoft.com/en-us/library/ms752347.aspx相对=nofollow>数据绑定是的非常的相关信息。)

(DataSource is used in Windows Forms, you normally will not encounter it in WPF. If you want to understand DataContexts you need to read up on data binding which is very useful.)

这篇关于添加字符串数组组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆