Вы должны ссылаться на DataTemplate
как ItemTemplate
в вашем ListBox
.Определите Key
в вашем DataTemplate
.
<Window.Resources>
<DataTemplate x:Key="MyItemTemplate" DataType="{x:Type local:Photo}">
<Border Margin="3">
<Image Source="{Binding Source}"/>
</Border>
</DataTemplate>
</Window.Resources>
<ListBox Name="listBox" ItemsSource="{Binding MyPhotos}" Background="Silver" Width="600" Margin="10" SelectedIndex="0" ItemTemplate="{StaticResource MyItemTemplate}"/>
ОБНОВЛЕНИЕ
Измените свой DataContext на this
.
listBox.DataContext = this;