Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 533463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:30:40+00:00 2026-05-13T09:30:40+00:00

In my Silverlight app I have UserControl and I want to reference a StaticResource

  • 0

In my Silverlight app I have UserControl and I want to reference a StaticResource in a ResourceDictionary that is in a separate XAML file.

My UserControl looks like this:

<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>

My SampleData.xaml file looks like this:

<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>

I have the SampleData.xaml file set to a Build Action of Content and when I run the app I get an AG_E_PARSER_BAD_TYPE [Line: 5 Position: 44] error on the InitializeComponent() line of the constructor for my UserControl.

What is causing this error and how can I correctly reference this resource?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:30:40+00:00Added an answer on May 13, 2026 at 9:30 am

    This line in your resource dictionary doesn’t look right to me:-

     xmlns:Headache="clr-namespace:ResourceDictionaryHeadache"
    

    Is your PersonList class really defined in a Namespace called ResourceDictionaryHeadache?

    Whether it is or isn’t I suspect that the reason the code it failing is because XAML can’t find the PersonList type.

    Edit

    D’Oh! I just noticed, remove the preceding / from the Source and leave the SampleData.xaml Resource dictionary at its default Build Action of “Page”.

    In other words if you just added the XAML file using “Add New Item” then “Resource Dictionary” you would only need this in your page xaml:-

    <UserControl.Resources> 
        <ResourceDictionary Source="SampleData.xaml" /> 
    </UserControl.Resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a silverlight app that I want to support plugin development for. I'm
I have made a Silverlight app that contain a class and I want to
This morning I tried running a Silverlight 5 App that we have been building
I have created a silverlight app that consits of like buttons within specific usercontrols
In my Silverlight app I have an event handler that dynamically creates a new
I have a silverlight app that will be installed OOB with full trust and
I have a Silverlight app that has to load an image dynamically, depending on
I have a WCF web-service and a Silverlight app displaying data from that service.
I have a Silverlight app that uses actions to get data from the model
I have a Silverlight app that has a bunch of styles that are referenced

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.