简体   繁体   English

C#surface 2数据源

[英]C# surface 2 DataSource

I am working in Visual C# -> surface -> v2.0 -> Surface Application (WPF) template in MS visual C# 2010 express. 我正在Visual C#-> Surface-> v2.0-> MS Visual C#2010 Express中的Surface应用程序(WPF)模板中工作。

I am trying to get the inputs on the surface table (Samsung SUR40) and parse these to a JSON array. 我正在尝试获取表面表(Samsung SUR40)上的输入并将它们解析为JSON数组。

Each input I want to add as an item in a listbox including an item id to find these back later if the input is moving. 我想将每个输入添加为包含项目ID的列表框中的项目,以便在输入移动时稍后找到它们。

I found this example and get an error like: 我找到了这个例子,并得到一个类似的错误:

C:\\Users\\User\\documents\\visual studio 2010\\Projects\\SurfaceInputs\\SurfaceInputs\\SurfaceWindow1.xaml.cs(209,25): error CS1061: 'System.Windows.Controls.ListBox' does not contain a definition for 'DataSource' and no extension method 'DataSource' accepting a first argument of type 'System.Windows.Controls.ListBox' could be found (are you missing a using directive or an assembly reference?) C:\\ Users \\ User \\ Documents \\ Visual Studio 2010 \\ Projects \\ SurfaceInputs \\ SurfaceInputs \\ SurfaceWindow1.xaml.cs(209,25):错误CS1061:'System.Windows.Controls.ListBox'不包含'DataSource'的定义'并且找不到扩展方法'DataSource'接受类型为'System.Windows.Controls.ListBox'的第一个参数(您是否缺少using指令或程序集引用?)

The same error occurs for the DisplayMember and the ValueMember. DisplayMember和ValueMember发生相同的错误。

After the failed example I tried this piece of code which give me the same error: 在失败的示例之后,我尝试了这段代码,该代码给了我同样的错误:

List<string> list = new List<string>();
list.Add("Hello World");
myListBox.DataSource = list;

I'm a newb at C# and dont know what i'm doing wrong. 我是C#的新手,不知道我在做什么错。 Could anyone help me? 有人可以帮我吗?

Try myListBox.ItemsSource = list . 试试myListBox.ItemsSource = list

See MSDN for the docs. 有关文档,请参见MSDN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM