I want to understand the example from msdn
(http://msdn.microsoft.com/en-us/library/ms742521.aspx#defining_simple_datatemplate).
XAML Code:
<ListBox Width="400" Margin="10" ItemsSource="{Binding Source={StaticResource MyTodoList}}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=TaskName}" />
<TextBlock Text="{Binding Path=Description}"/>
<TextBlock Text="{Binding Path=Priority}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The Data in the Text Blocks are Properties from an Object, is this right?
The Object is in the List (?) myTodoList in the code behind file?
protected ObservableCollection<TODO> _myTodoList= new ObservableCollection<TODO>();
public ObservableCollection<TODO> MyTodoList
{
get { return _myTodoList; }
}
Add TODO’s
TODO t1 = new TODO();
t1.TaskName = "TaskName1";
t1.Description = "Description1";
t1.Priority = "Priority1";
_myTodoList.Add(t1);
TODO t2 = new TODO();
t2.TaskName = "TaskName2";
t2.Description = "Description2";
t2.Priority = "Priority2";
_myTodoList.Add(t2);
My Test TODO Class:
public class TODO
{
public string TaskName { get; set; }
public string Description { get; set; }
public string Priority { get; set; }
}
But the code throws an exception…

whats wrong?
You have to declare the StaticResource:
From the SDKSample: