Im new to data binding in Windows Phone 7 and cannot get this code to work. First, here is my "Move" Class:
public class Move
{
public string RollNumber {get; set;}
public string Description {get; set;}
}
Now here is my list which is made upon loading the page:
public Game()
{
InitializeComponent();
Loaded += new RoutedEventHandler(Game_Loaded);
}
void Game_Loaded(object sender, RoutedEventArgs e)
{
List<Move> Moves = new List<Move>();
Move thisMove = new Move();
thisMove.RollNumber = "6";
thisMove.Description = "Danny Winrars with a 6";
Moves.Add(thisMove);
GameHistoryList.ItemsSource = Moves;
}
Finally, here is my XAML:
<ListBox Name="GameHistoryList">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding RollNumber}"></TextBlock>
<TextBlock Text="{Binding Description}"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Anyone have any ideas on why this doesn't work? :)