WPF : Access Application Resources when not referencing Shell from App.xaml
Posted
by CF_Maintainer
on Stack Overflow
See other posts from Stack Overflow
or by CF_Maintainer
Published on 2010-05-23T18:38:42Z
Indexed on
2010/05/23
18:40 UTC
Read the original article
Hit count: 308
I am beginner in WPF. My App.xaml looks like below
app.xaml
<Application x:Class="ContactManager.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<Color x:Key="lightBlueColor">#FF145E9D</Color>
<SolidColorBrush x:Key="lightBlueBrush"
Color="{StaticResource lightBlueColor}" />
</Application.Resources>
I do not set the startupuri since I want to a presenter first approach. I do the following in app.xaml.cs
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var appPresenter = new ApplicationPresenter(
new Shell(), new ContactRepository());
appPresenter.LaunchView();
}
I have a usercontrol called "SearchBar.xaml" which references "lightBlueBrush" as a staticResource.
When I try to open "Shell.xaml" in the designer it tells me : The "shell.xaml" cannot be loaded at design time because it says it could not create an instance of type "SearchBar.xaml".
When I debugged the devenv.exe using another visual studio instance it tells me that it does not have access to the Brush I created in app.resources.
If one is doing a Presenter first approach, how does one access resources?
I had this working when the startupURI was "Shell.xaml" and the startup event was not present.
Any clues/ideas/suggestions. I am just trying to understand.
Everything works as expected when I run the application just not @ design time.
© Stack Overflow or respective owner