Hello all,

I came across the following issue in my MVVM application.

This is my MainWindow xaml where I am subcribing the MainWindowResources.xaml in the Window.Resources to obtain my Styles.
Code:
<Window x:Class="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"
        Title="MVVM Light View Switching"
        d:DesignHeight="500"
        d:DesignWidth="800"
        DataContext="{Binding Main, Source={StaticResource Locator}}"
        ResizeMode="NoResize"
        SizeToContent="WidthAndHeight"
        mc:Ignorable="d">
    <Window.Resources>
        <ResourceDictionary Source="MainWindowResources.xaml"/>
    </Window.Resources>
    
    <Grid>
    
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
        </Grid.ColumnDefinitions>
        
<ContentControl Content="{Binding CurrentViewModel}" />

        <DockPanel Grid.Row="1" Margin="5" Height="auto">
                 
            <Button Style="{StaticResource ButtonStyle}"
                    Command="{Binding SecondViewCommand}"
                    Content="Second View"
                    DockPanel.Dock="Right" />
            <Button Style="{StaticResource ButtonStyle}"
                    Command="{Binding FirstViewCommand}"
                    Content="First View"
                    DockPanel.Dock="Left" />
        </DockPanel>
        
    </Grid>
</Window>
And my MainWindowResources.xaml below:

Code:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    <Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}">
        <Setter Property="FontSize" Value="32pt" />
        <Setter Property="Background" Value="AliceBlue"/>
    </Style>
    
    <Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Height" Value="30"/>
        <Setter Property="Width" Value="100"/>
    </Style>
    
</ResourceDictionary>


I have another usercontrol for my frist view:

Code:
<UserControl x:Class="Views.FirstView"
             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"
  
             d:DesignHeight="500"
             d:DesignWidth="800"
             mc:Ignorable="d">
    <UserControl.Resources>          
ResourceDictionary Source="FirstViewResources.xaml"
    </UserControl.Resources>


        <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" MinWidth="159" />
            <ColumnDefinition Width="Auto" MinWidth="141" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
            
        <Button Command="{Binding ShowPopUp}"
                Style="{StaticResource ButtonStyle}"
                Content="Show Pop Up" />
        <Button Command="{Binding IncrementValue}"
                Style="{StaticResource ButtonStyle}"            
                Grid.Row="1"
                Content="Increment value" />
        <TextBlock Grid.Row="1"
                   Grid.Column="1"
                   MinWidth="50"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"

                   TextAlignment="Center" Height="16" Margin="51,3,40,3" Width="50" />


        <StackPanel Grid.Column="1" Grid.Row="2">
            <TextBox Text="{Binding Value1}" Style="{StaticResource TextBoxStyle}"/>
            <TextBox Text="{Binding Value2}" Style="{StaticResource TextBoxStyle}" />
            <TextBox Text="{Binding Value3}" Style="{StaticResource TextBoxStyle}"/>
            <TextBox Text="{Binding Value4}" Style="{StaticResource TextBoxStyle}"/>
            <TextBox Text="{Binding Value5}" Style="{StaticResource TextBoxStyle}"/>
            <TextBox Text="{Binding Value6}" Style="{StaticResource TextBoxStyle}"/>
            <TextBox Text="{Binding ArtistName}"/>
            <Button Margin="50" Command="{Binding AddParentValues}">Calculate symmaries!</Button>
            <WrapPanel Margin="10">
                <TextBox Width="Auto" Text="{Binding ParentValues}" />
                <TextBox Width="Auto" Text="{Binding ChildValues}" />
            </WrapPanel>
        </StackPanel>


    </Grid>
</UserControl>

With a pretty much similar FirstViewResources.xaml
Code:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Height" Value="23"/>
        <Setter Property="Background" Value="Cornsilk"/>
    </Style>
    <Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}">
        <Setter Property="Height" Value="23"/>
        <Setter Property="Width" Value="auto"/>
    </Style>

</ResourceDictionary>
However, for my for my FirstView I am getting an exception error. "An error occurred while finding the resource dictionary "FirstViewResources.xaml"."

And Also in the designer view I am getting another error message:

" at Microsoft.Expression.WpfPlatform.InstanceBuilders.ResourceDictionaryInstanceBuilder.ProvideResourceD ictionary(IInstanceBuilderContext context, ViewNode viewNode, IDocumentRoot& relatedRoot, ResourceDictionary& originalInstance)
at Microsoft.Expression.WpfPlatform.InstanceBuilders.ResourceDictionaryInstanceBuilder.UpdateProperty(I InstanceBuilderContext context, ViewNode viewNode, IProperty propertyKey, DocumentNode valueNode)
at Microsoft.Expression.WpfPlatform.InstanceBuilders.ResourceDictionaryInstanceBuilder.InstantiatePrope rties(IInstanceBuilderContext context, ViewNode viewNode, DocumentCompositeNode compositeNode)
at Microsoft.Expression.Platform.InstanceBuilders.DictionaryInstanceBuilder.Initialize(IInstanceBuilder Context context, ViewNode viewNode, Boolean isNewInstance)
at Microsoft.Expression.Platform.InstanceBuilders.ViewNodeManager.InitializeInstance(IInstanceBuilder builder, ViewNode viewNode, Boolean isNewInstance)"

which I cannot really explain. Maybe anyone has an idea why it doesn't work for the FirstView but it does for the MainWindow? Maybe it has to do with namespace definitions?

thanks!