1
我下面的MSDN數據模板概述http://msdn.microsoft.com/en-us/library/ms742521.aspxMSDN數據模板化概述
但我覺得他們錯過了解釋something..for資源他們有:
<Window.Resources><local:Tasks x:Key="myTodoList"/></Window.Resources>
而且他們都在XAML中已經是
<ListBox Width="400" Margin="10"
ItemsSource="{Binding Source={StaticResource myTodoList}}"/>
沒有顯示C#代碼的後面,他們能夠顯示列表框中的項目列表。列表框沒有X:名稱,我不能在主窗口中添加的項目,並與一個單獨的類的任務,我做了以下(不工作)
using System.Collections; // use ArrayList
using System.Collections.ObjectModel; // use Observable Collection
namespace FooApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
public class Tasks : ObservableCollection<Tasks>
{
string TaskName;
string Description;
int Priority;
public TasksStuff(string taskName, string description, int priority)
{
this.taskName = TaskName;
this.description = Description;
this.priority = Priority;
}
public string TaskName
{get{return this.taskName}}
public string Description
{get{return this.description}}
public string Priority
{get{return this.priority}}
private ArrayList Tasks
{
ArrayList taskList = new ArrayList();
taskList.Add(new TasksStuff("A foo task", "doing foo",1));
return taskList;
}
}
}
我真的很困惑。
+1或IList的'',或'IBindingList'等 –
user7116
2010-12-15 15:14:24
我不能datalist.Add添加到ArrayList類。我應該如何添加到陣列? – KMC 2010-12-15 15:21:32
我不明白,你能提供代碼嗎? – decyclone 2010-12-15 15:23:55