I did quite a bit of WPF a couple of years ago but seem to have forgotten everything.
Suppose I have a simple business class, say a TFS workitem.
public class WorkItem
{
public WorkItem(string name, DateTime date)
{
Name = name;
Date = date;
}
public string Name { get; set; }
public DateTime Date { get; set; }
}
Then I have a list of WorkItems, perhaps something like this.
class WiList : ObservableCollection<WorkItem>
{
public WiList () : base()
{
Add(new WorkItem("1", DateTime.Now));
Add(new WorkItem("2", DateTime.Now));
}
}
Then I have a UserControl that represents a WorkItem, something like this.
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="WrapPanelItemsControlTest.WorkItemControl"
x:Name="UserControl"
d:DesignWidth="640" d:DesignHeight="480" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="72" Height="40">
<StackPanel x:Name="LayoutRoot">
<TextBlock x:Name="Name"/>
<TextBlock x:Name="Date"/>
</StackPanel>
The main window contains a WrapPanel to hold the UserControls. My question is, how do I create a WrapPanel that binds to the WiList and displays the WorkItems? I remember doing something like this before, but for the death of me I can't remember how (probably something from Bea Costa's blog). Of course I can't find my old test code anywhere and seem to be expectionally bad at googling for examples.
Any help is appreaciated.