public
Last active

ResourceDictionary error in Silverlight

  • Download Gist
MainPage.xaml
XML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<UserControl x:Class="ResourceDictionaryHeadache.MainPage"
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" d:DesignWidth="640" d:DesignHeight="480">
<UserControl.Resources>
<ResourceDictionary Source="/SampleData.xaml" />
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<ListBox HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ItemsSource="{StaticResource SampleData}">
</ListBox>
</Grid>
</UserControl>
Person.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13
using System;
using System.Collections.ObjectModel;
 
namespace ResourceDictionaryHeadache
{
public class PersonList : ObservableCollection<Person> { }
 
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
}
SampleData.xaml
XML
1 2 3 4 5 6 7 8 9 10
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Headache="clr-namespace:ResourceDictionaryHeadache">
<Headache:PersonList x:Key="SampleData">
<Headache:Person Name="Joe" Age="20" />
<Headache:Person Name="Sam" Age="25" />
<Headache:Person Name="Dave" Age="30" />
</Headache:PersonList>
</ResourceDictionary>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.