Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding a simple business class to a WPF UserControl
    primarykey
    data
    text
    <p>I did quite a bit of WPF a couple of years ago but seem to have forgotten everything.</p> <p>Suppose I have a simple business class, say a TFS workitem.</p> <pre><code>public class WorkItem { public WorkItem(string name, DateTime date) { Name = name; Date = date; } public string Name { get; set; } public DateTime Date { get; set; } } </code></pre> <p>Then I have a list of WorkItems, perhaps something like this.</p> <pre><code>class WiList : ObservableCollection&lt;WorkItem&gt; { public WiList () : base() { Add(new WorkItem("1", DateTime.Now)); Add(new WorkItem("2", DateTime.Now)); } } </code></pre> <p>Then I have a UserControl that represents a WorkItem, something like this.</p> <pre><code>&lt;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"&gt; &lt;StackPanel x:Name="LayoutRoot"&gt; &lt;TextBlock x:Name="Name"/&gt; &lt;TextBlock x:Name="Date"/&gt; &lt;/StackPanel&gt; </code></pre> <p></p> <p>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.</p> <p>Any help is appreaciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload