Im getting this exception:
'Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '13' and line position '6'.
when i attempt to run the following XAML:
<Window x:Class="WPF_Application.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:me="clr-namespace:WPF_Application"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<DataTemplate DataType="me:ExampleBusinessObject" x:Key="BusinessObjectTemplate">
<StackPanel>
<Label HorizontalAlignment="Center" Content="{Binding Path=Title}"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
<ItemsControl ItemsSource="{Binding BusinessObjects}" ItemTemplate="{StaticResource BusinessObjectTemplate}"/>
</Window>
From what i can tell, this is normally caused by thing the static resource extension is pointing to not being available, but as far as im aware the template should be available at that point.
I'd suggest removing the datatype as mentioned above or removing the itemtemplate from the itemscontrol.
The reason your getting this error is your providing 2 conflicting bits of information. By setting the datatype you are telling WPF to use this datatemplate whenever the type of object is ExampleBusinessObject. By setting the ItemTemplate your are telling WPF to use this datatemplate at all times. Use one or the other.