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 4231854
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:01:20+00:00 2026-05-21T02:01:20+00:00

I have WPF project and some resources defined in App.xaml that are used in

  • 0

I have WPF project and some resources defined in App.xaml that are used in other files. When I try to move App.xaml to subdirectory designer is no longer able to find those resources. My project still compiles since I use ‘Startup’ event instead of ‘StartupUri’. How to tell the designer where to search for resources? How it knows where they are when App.xaml is in root of project?

Update:
Project files:

App.xaml:

<Application x:Class="WpfApplication1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             Startup="startup">
    <Application.Resources>
        <SolidColorBrush Color="LightGray" x:Key="brush" />
    </Application.Resources>
</Application>

App.xaml.cs

namespace WpfApplication1
{
    public partial class App : System.Windows.Application
    {
        private void startup(object sender, System.Windows.StartupEventArgs e)
        {
            new MainWindow().Show();
        }
    }
}

MainWindow.xaml:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Height="300" Width="300" Background="{StaticResource brush}" />

MainWindow.xaml.cs

namespace WpfApplication1
{
    public partial class MainWindow : System.Windows.Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}

Update 2:
Uploaded zipped solution to http://zalil.ru/30771604 (download will start automatically)

Mirror: http://www.speedyshare.com/files/27697250/WpfApplication1.zip

  • 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-21T02:01:20+00:00Added an answer on May 21, 2026 at 2:01 am

    I can’t duplicate the problem on my end. Here’s what I tried:

    I created a application with a style in the resources of App.xaml. I moved App.xaml to a subdirectory. I have another window that uses the style defined in the resources of App.xaml (he resides in a different directory) and it was able to resolve it just fine. I added ..\ to the beginning of my original StartupUri.

    I did some searching, what version of Visual Studio are you using? Apparently there may be an bug related to your problem in VS2008:

    http://bengribaudo.com/blog/2010/08/19/106/bug-single-application-resources-entry-ignored

    He says a workaround for this bug is to set the x:Name attribute on Application. Hope that helps!

    EDIT: I also tried handling the Startup event instead of using the StartupUri and it still worked fine.

    public partial class App : Application
    {
         private void Application_Startup(object sender, StartupEventArgs e)
         {
              new MainWindow().Show();
         }
    }
    

    EDIT PART 2:

    Okay, I enclosed the SolidColorBrush inside a ResourceDictionary as such:

    <ResourceDictionary>
         <SolidColorBrush Color="LightGray" x:Key="brush" /> 
    </ResourceDictionary>
    

    And the window picks up the brush. The designer doesn’t like it, but when I change from StaticResource to DynamicResource it stops complaining.

    EDIT 3:

    I just thought of something. Do you have VS2010 SP1 installed? It fixed some bugs with the designer.

    And sorry, my edit number 2 didn’t work as expected. I noticed my blue squiggles were gone in the xaml, but I didn’t check the designer. x__x

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my project I have a DLL for some WPF/XAML controls that need to
I have some storyboards in XAML (WPF Project) and I´m calling them from the
I have a WPF VB.NET project in Visual Studio 2008. For some reason, Visual
I have a WPF project using CM. I have a progress bar that I
I have a grid in a XAML file in a WPF project. This MainGrid
I have built a Wpf-ControLibrary-Project to put some Controls there. In one Control i
In my WPF project I have a custom control with some properties assigned, they
I have a .NET 4.0 WPF project. When I open a FileDialog, choose some
I have a vs2010 solution with many project (WPF control library, some business logic
I have a WPF project written in C#, and in order to get some

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.