Testing a WPF Window with StaticResources - wpf

I have a simple Window with a reference to a StaticResource in the App.xaml.
App.xaml resource definition:
<!-- Standard Text Box Style -->
<Style x:Key="textBoxStyleStd" TargetType="{x:Type TextBox}">
<Setter Property="FontSize" Value="14" />
</Style>
Window componets using the resource:
<TextBlock Grid.Column="1" Grid.Row="0" Name="stationIdTitle"
Style="{StaticResource textBlockStyleStd}"
VerticalAlignment="Center" HorizontalAlignment="Center"
Text="{LocText Key=Title, Dict={StaticResource Dictionary},
Assembly={StaticResource Assembly}}"/>
When trying to unit test this Window I get the error:
System.Windows.Markup.XamlParseException: Cannot find resource named
'{textBlockStyleStd}'. Resource names are case sensitive. Error at
object 'stationIdTitle' in markup file
'Zpg;component/guicomponenets/screens/enterstationidscreen.xaml' Line
23 Position 71.
Is there any way around this? My unit test code is:
[Test]
public void TestEnterKeyPressedNoText()
{
IPickingBusinessObject pickingBusinessObject = mock.StrictMock<IPickingBusinessObject>();
EnterStationIdScreen objectUnderTest = new EnterStationIdScreen(pickingBusinessObject);
Assert.AreEqual(Visibility.Visible, objectUnderTest.stationIdError.Visibility);
Assert.AreEqual("werwe", "oksdf");
Replay();
objectUnderTest.EnterKeyPressed();
Verify();
}

Thanks Kent,
I looked at your suggestions and in most scenarios I agree models should be used and tested however, there is some code associated with the controls (e.g. TextBox visibility) I still wanted to test. To get round this you can create an instance of your Application (but not initialize it) and add the resources manually. This does lead to duplication in the App.xaml and the base unit test but this allows me to complete the tests I wanted.
if (Application.Current == null)
{
App application = new App();
#region Add Static Resources from the App.xaml
Style textBoxStyle = new Style(typeof(TextBox));
textBoxStyle.Setters.Add(new Setter(TextBox.FontSizeProperty, 14d));
Style textBlockStyle = new Style(typeof(TextBlock));
textBlockStyle.Setters.Add(new Setter(TextBlock.FontSizeProperty, 14d));
application.Resources.Add("TextBoxStyleStd", textBoxStyle);
application.Resources.Add("TextBlockStyleStd", textBlockStyle);
application.Resources.Add("TextBlockStyleError", textBlockStyle);
application.Resources.Add("Assembly", "Zpg");
#endregion
}

In the context of your unit test, there is no WPF application running. Therefore, the Window won't find the resource.
My way around this would be to not unit test your views. Instead, use MVVM and unit test your view models. If you want to test your views, write integration tests instead. Your integration tests can actually kick off the application and therefore much more closely imitate the real running of your app.

When I use fully qualified assembly names in my app.xaml resource entries, I only need to instanciate the App() class. In this example, all resources lies in the Majesty_of_Omega_GUI assembly, which is referred by the UnitTest.DLL
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Majesty_of_Omega.GUI.App"
StartupUri="Pages/MainPage.xaml"
>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Majesty_of_Omega_GUI;component/Resources/MainScreens.xaml" />
<ResourceDictionary Source="pack://application:,,,/Majesty_of_Omega_GUI;component/Resources/PanelResources.xaml" />
<ResourceDictionary Source="pack://application:,,,/Majesty_of_Omega_GUI;component/Simple Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Test function:
[Test]
public void Testfunction()
{
if (Application.Current == null)
{
App application = new App();
}
SomePage page = new SomePage();

Actually, you can use the same Application and if the resources are from the same assembly, you've got to call the InitializeComponents methods to make it works (Source here).
Have a nice day !

Related

Get ResourceDictionary source from static member with design-time support

My basic goal is to have a ResourceDictionary in a dll which I can use in another WPF project via ResourceDictionary.MergedDictionaries. But I don't want to reference the ResourceDictionary by hard-coding the URI in the XAML of the referencing application, I want to instead reference some static member which will provide the URI.
I have some simplified code which is "working", but only at runtime. At design-time it throws errors and I get no IntelliSense support. For this simplified example, everything is in one assembly (no separate dll).
Dic.xaml (the resource dictionary I want to reference):
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush Color="Blue" x:Key="BlueBrush"/>
</ResourceDictionary>
Foo (the module to hold the static member with the URI):
(VB.NET version)
Public Module Foo
'[VBTest] is the name of assembly
Public ReadOnly Property URI As New Uri("pack://application:,,,/VBTest;component/Dic.xaml")
End Module
(C# version)
public static class Foo
{
//[VBTest] is the name of assembly
public static Uri URI { get; } = new Uri("pack://application:,,,/VBTest;component/Dic.xaml");
}
And then finally, the place in the application where I want to reference the ResourceDictionary:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VBTest">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="{x:Static local:Foo.URI}"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Border Width="100" Height="100" Background="{StaticResource BlueBrush}"/>
</Window>
At design-time, I get two errors:
XDG0062 An error occurred while finding the resource dictionary "".
XDG0062 The resource "BlueBrush" could not be resolved.
However, the project will build and run just fine. And will show the intended blue square.
The question is, how can I get this to work at design-time?
I found a thankfully easy workaround. Maybe not the prettiest, but it is elegant. I took inspiration from this answer to a somewhat related question.
By creating my own class inheriting from ResourceDictionary, I can better control the loading behavior. That sounds like it would be complicated, but really all I had to do was set Source as part of the constructor and everything just worked.
The below is added to the code file (outsite of Module/static class Foo):
Public Class StylesResourceDictionary
Inherits ResourceDictionary
Public Sub New()
MyBase.New()
Source = URI
End Sub
End Class
Note that Source = URI is referencing Foo.URI from the question code.
And then the XAML file becomes:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VBTest">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<local:StylesResourceDictionary/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Border Width="100" Height="100" Background="{StaticResource BlueBrush}"/>
</Window>
And bam, full design-time support without hard-coding the URI into the referencing application. Control of the ResourceDictionary and its URI is now in the domain of the dll, and can be referenced in a (kinda) static fashion using the dedicated class.

WPF, Simple Injector and MaterialDesignThemes Static resource invalid

I have sample app written in WPF and using Simple Injector and Material Design Themes.
This is my program file:
private static Container Bootstrap()
{
// Create the container as usual.
var container = new Container();
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
// Register your types, for instance:
container.Register<IFreewayReviewCreatorDbContext, FreewayReviewCreatorDbContext>(Lifestyle.Scoped);
container.Register<IUnitOfWorkFactory, UnitOfWorkFactory>(Lifestyle.Transient);
container.Register<IUnitOfWork, UnitOfWork>(Lifestyle.Scoped);
container.Register<IReviewBodyBLL, ReviewBodyBLL>(Lifestyle.Transient);
// Register your windows and view models:
container.Register<MainWindow>();
container.Register<MainWindowViewModel>();
container.Verify();
return container;
}
private static void RunApplication(Container container)
{
try
{
var app = new App();
//app.InitializeComponent();
var mainWindow = container.GetInstance<MainWindow>();
app.Run(mainWindow);
}
catch (Exception ex)
{
//Log the exception and exit
}
}
In the code above view models add registered in Simple Injector.
Now in MainWindow I want to use StaticResource from Material Design. This is my code:
<Window x:Class="FreewayReviewCreator.MainWindow"
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"
xmlns:local="clr-namespace:FreewayReviewCreator"
xmlns:localvm="clr-namespace:FreewayReviewCreator.ViewModel"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d" Loaded="MainWindow_OnLoaded"
Title="MainWindow" Height="450" Width="800">
<Grid>
<StackPanel HorizontalAlignment = "Left">
<TextBox
Name="tbxPassword"
Text="{Binding Password, Mode = TwoWay}"
HorizontalContentAlignment="Center"
Style="{StaticResource MaterialDesignFloatingHintTextBox}"
MaxLength="28"
materialDesign:HintAssist.Hint="Enter your username"
/>
Error is in this line: Style="{StaticResource MaterialDesignFloatingHintTextBox}":
System.Windows.Markup.XamlParseException: ''Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '44' and line position '21'.' Exception: Cannot find resource named 'MaterialDesignFloatingHintTextBox'. Resource names are case sensitive.
On this webpage is sample application with StaticResource (I took code from this app):
https://www.c-sharpcorner.com/article/wpf-application-with-googles-material-design/
and it works. The only one difference that I can see is that my application has Simple Injector and app from sample doesn't have.
References are the same in both of apps:
You should install the MaterialDesignThemes NuGet package and add the following resource dictionaries to your App.xaml file as described in the docs:
<?xml version="1.0" encoding="UTF-8"?>
<Application . . .>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
This has nothing to do with simple injector or whatever IoC container you are using.
You need to import the resources into your app to be able to use them.
Assuming you provide the ResourceDictionaries to the App class as given in the answer of #mm8, you should load and apply the ResourceDictionaries by calling InitializeComponent() in the constructor of the App class.
Like this:
public partial class App : Application
{
public App()
{
this.InitializeComponent();
}
}
I see in your question that commented this line out. This is probably the result of following the provided startup code from Simple Injector documentation and after this adding the Material Design Themes.
This code is however necessary when you add MergedDictionaries to you App.xaml. So you need to add it back.

Resources not resolving from ResourceDictionaries

I'm having problems resolving Resources from my ResourceDictionaries.
I decided to refactor my rather large ResourceDictionary into individual dictionary files, organized into subfolders.
I have a ResourceLibrary.xaml under Resources:
<ResourceDictionary x:Class="MyProject.Resources.ResourceLibrary"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<!-- Colours -->
<ResourceDictionary Source="Colors/ConnectedCellColor.xaml" />
<!-- Brushes -->
<ResourceDictionary Source="Brushes/ConnectorCellBrush.xaml" />
<!-- Control Templates -->
<ResourceDictionary Source="ControlTemplates/ConnectorCellTemplate.xaml" />
<!-- Base Styles -->
<ResourceDictionary Source="BaseStyles/ConnectorBaseStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
The class is there for a reason, in the code behind, I can add [Export(typeof (ResourceDictionary))] so MEF can find it.
I have a View: (simplified)
<UserControl x:Class="MyProject.ConnectorCellView"
Style="{StaticResource ConnectorBaseStyle}"
</UserControl>
ConnectorBaseStyle:
<ResourceDictionary>
<Style x:Key="ConnectorBaseStyle" TargetType="UserControl">
<Setter Property="Template" Value="{StaticResource ConnectorCellTemplate}" />
</Style>
</ResourceDictionary>
The template has StaticResources to try and get a Brush and a colour.
All of these StaticResources will not resolve any more.
I thought it might have been an order issue, but since these resources are contained in a plugin to my main program, I use MEF and ImportMany to get all the exported ResourceDictionaries, and in my Caliburn.Micro bootstrapper:
public void OnImportsSatisfied()
{
foreach (ResourceDictionary resourceDictionary in ResourceDictionaries)
{
Application.Resources.MergedDictionaries.Add(resourceDictionary);
}
}
(Neat trick I found somewhere)
I can actually run my program, and when that view is created it throws an exception when trying to set the style:
System.InvalidCastException
Unable to cast object of type 'MS.Internal.NamedObject' to type System.Windows.FrameworkTemplate'.
The only information I've found relating to this has to do with the order resources are defined, but from the order I have them in ResourceLibrary, it should work.
When the exception is thrown, I can examine Application.Current.Resources.MergedDictionaries,
and see the resources.
I've tried various ways of specifying the Source in ResourceLibrary
<ResourceDictionary Source="/MyProject;component/Resources/BaseStyles/ConnectorBaseStyle.xaml" />
etc, no effect on finding them. These resources are only used by the plugin code.
The only thing that seemed to work was changing all the StaticResources to DynamicResources
which doesn't make sense to me, if it is an order issue, why would Static work when they're all in the same file?
Some of my styles used BasedOn, and they don't work with DynamicResource.
Can you help me understand why this is happening, and how to make it work?
It is an ordering problem but not with the ordering of your merging - it's with the order of loading. Here's basically what happens when the ResourceLibrary dictionary loads:
ConnectedCellColor instantiates
ConnectedCellColor loads into ResourceLibrary
ConnectorCellBrush instantiates
ConnectorCellBrush loads into ResourceLibrary
ConnectorCellTemplate instantiates
ConnectorCellTemplate loads into ResourceLibrary
ConnectorBaseStyle instantiates
ConnectorBaseStyle loads into ResourceLibrary
The problem here is that where before with your single file you had a single instantiation step, you now have that broken up into multiple steps, each of which happen independently. When ConnectorBaseStyle is instantiated ConnectorCellTemplate has been loaded but ResourceLibrary's contents aren't known to ConnectorBaseStyle at this point. With DynamicResource this isn't a problem because those references can just resolve at step 8, but StaticResource requires immediate resolution at step 7.
The simplest fix is to use Dynamic wherever you can. For places that require Static (like BasedOn) you need to guarantee that the resource will be available during instantiation, either by also merging, for example, ConnectorCellTemplate into ConnectorBaseStyle, or by merging everything that's needed into App.xaml which is available to everything. This can make things complicated and hard to manage as you get more files and do merging into multiple places but at least the resource system is smart enough to recognize duplicates so in the case above you would still only get a single instance of ConnectorCellTemplate even though it is being merged at two places.

VS 2012: Failed to create a 'ImageSource' from the text

I am declaring an image within my resource dictionary and then displaying in a user control as follows:
ResourceDictionary.xaml (I am using a style here as I plan to update the image as the user changes what they look at, i.e., company, employee, etc.)
<ImageSource x:Key="CompanyIcon">Images/company_128.png</ImageSource>
<Style x:Key="QuickInfoIcon" TargetType="{x:Type Image}">
<!-- Default Value -->
<Setter Property="Source" Value="{StaticResource CompanyIcon}" />
</Style>
The 'Images' folder is a subfolder of 'Assests'. The 'Assests' folder contains my 'ResourceDictionary.xaml' file and I know the path is correct as I get a designer error if I change the path to something like '../Images/company_128.png'
QuickinfoView.xaml
<UserControl x:Class="SidekickAdmin.Views.QuickInfoView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" d:DesignWidth="500" Height="100"
Background="BlanchedAlmond">
<!-- Setup a grid to house the icon and the info -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Name="InfoIcon">
<Image Style="{StaticResource QuickInfoIcon}" Height="50" Width="50"/>
</Grid>
</Grid>
</UserControl>
When viewing the layout in Visual Studio 2012 designer, everything appears correctly but when I run the program I get an error of "XamlParseException occurred: Failed to create a 'ImageSource' from the text 'Images/employee_128.png'." on the ResourceDictionary line with ImageSource.
If I change ImageSource to use a different image it updates as expected within VS2012 designer but then get the same error when trying to run the program.
I have set the Build Action to 'Embedded Resource' on the Resource.resx file but this hasn't fixed the issue.
Any idea on why I am getting the XamlParseException when I try to run this program?
As a side question, when I incorporate images in my program should the image itself (the file) be visible in the bin/debug folder somewhere or is this information hidden with one of the files in bin/debug?
I had the same issue.
You may have a try for what fixed my issue.
Add the file into your project within the Solution Explorer.
I recommend to add folders too dependend on the relative path of your file to the project file.
Then go to:
BUILD -> clean Solution
Finish.
I, too, ran afoul of this issue. Not a single suggested provided by this or any community, most of which were verbatim statements about PACK uri's and other approaches solved the problem. Sadly, for all the enthusiasm people show in answering, most of them haven't a clue on how to fix it.
Setup: 1 solution, 2 projects.
Project 1 was a class library containing resource dictionary containing a list of BitMapSource entries pointing to the local relative path to the images contained below itself.
Example:
<BitmapSource x:Key="RedoImage">Images/Redo.png</BitmapSource>
Project 2 was a WPF application which referenced that class library and which used the MergedDictionary to load the dictionary from the other assembly:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/WPFResourceLibrary;component/Resources/images.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
In a form in the WPF Application project, I dropped a simple IMAGE control on the form. Under it's source property I could select, under LocalResources, from the list of BitMapSources (by key) from my images.xaml resource dictionary. Making a selection, the image would appear (as expected).
But lo and behold, upon running the application, I would get the dreaded "Failed to create image source from the text ..." message. I fiddled about trying all of the many suggestions, each with no success. Always either the same error, or, no error, but no image, at run time.
Fed up, I produced my own custom control. I chose to NOT override the image source property, so we might use that where appropriate, but extended it by adding a dependency property called ResourceName. This control looks through all of the BitMapSources and ImageSources recorded and available within the current app domain. Bingo, it works.
The code:
<Image x:Class="WPFResourceLibrary.Controls.ImageFromResource"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
>
</Image>
And the Code Behind for it.
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace WPFResourceLibrary.Controls
{
/// <summary>
/// ImageFromResource - an extension of the standard Image control that properly handles binding Resource to an Image from a Resource
/// </summary>
public partial class ImageFromResource : Image
{
public ImageFromResource()
{
InitializeComponent();
DependencyPropertyDescriptor imageDescriptor = DependencyPropertyDescriptor.FromProperty(ImageFromResource.ResourceNameProperty, typeof(ImageFromResource));
if (imageDescriptor != null)
{
imageDescriptor.AddValueChanged(this, delegate { SetImage(); });
}
}
public static DependencyProperty ResourceNameProperty = DependencyProperty.Register("ResourceName", typeof(ImageSource), typeof(ImageFromResource), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
[Description("Resource String of the Target Image."), Category("Appearance")]
public ImageSource ResourceName
{
get { return (ImageSource)GetValue(ResourceNameProperty); }
set
{
SetValue(ResourceNameProperty, value);
}
}
private void SetImage()
{
if(ResourceName != null)
this.Source = new BitmapImage(new Uri(ResourceName.ToString()));
}
}
}
Thus, providing the functionality expected of the standard image, without the issues arising.
Note, this was performed in Visual Studio 2012 with SP3.
Paul

Application-level Resources in a Different Assembly

This question involves the Visual Studio (2008) WPF Designer's apparent inability to handle the usage of resources located at the App.xaml level if the App.xaml is in a separate assembly from the view.
To simplify the explanation of the problem I have created a test application. This application has two assemblies: View and Start. The View assembly contains a xaml window called Window1, and the Start assembly includes the App.xaml file. The App.xaml file in the Start assembly has its StartupUri set to the Window1 in the View assembly. Neither of these files have code-behinds (aside from the standard constructors and InitializeComponent() call).
The code for this example is as follows:
App.xaml:
<Application x:Class="Start.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="pack://application:,,,/View;component/Window1.xaml"
>
<Application.Resources>
<!-- Warning Text Style -->
<Style x:Key="WarningTextStyle" TargetType="TextBlock">
<Setter Property="FontWeight" Value="Bold" />
</Style>
</Application.Resources>
Window1.xaml:
<Window x:Class="View.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1"
Height="300"
Width="300"
>
<Grid>
<TextBlock Text="This is test text" Style="{StaticResource WarningTextStyle}" />
</Grid>
</Window>
The Window1.xaml file contains a single TextBlock that references the App-level WarningTextStyle. This code works fine at runtime because the Window properly finds the App-level resource; however, at design-time the designer complains that it cannot find the WarningTextStyle.
Does anybody know of a clean and scalable solution to this problem?
My standard approach with large applications is to organize my app-level resources into resource dictionary files, and then merge those dictionaries in the App.xaml. To work around the problem that I've described above I have to merge those resource dictionaries into each view's resources. This seems very inefficient, and if I later add another resource dictionary then I need to merge that new dictionary into every view.
A silver bullet solution would re-direct the designer to find the app-level resources. A reasonable work around would be the merging of the app-level resource dictionaries into each view, but only at design-time. At runtime I would like to avoid merging these dictionaries in every view because of the efficiency issues.
I've tried merging the dictionaries on each view in the view's code-behind constructor, and then wrapping that logic in an if statement that checks the DesignerProperties.GetIsInDesignMode() method; however, the Visual Studio designer does not run the view's constructor - so this approach appears to be a bust.
Does anybody have a better solution or work around?
Can you merge the resource dictionary in your referenced assembly (be it App.xaml or your own resource dictionary) from your main (exe) assembly's App.xaml?
I just had a different idea: use a DynamicResource instead of a Static one. This might introduce a tiny performance hit, but I doubt it would be measurable.

Resources