Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to split app.xaml into several xaml-files. It seems to work for most things, but not for things reffering to clr-namespace. I started out by moving "everything" from app.xaml to another file. I'll try to explain with a small example.

App.xaml
C#
<Application x:Class="Preparation.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:src="clr-namespace:Preparation.DataModel" 
             xmlns:conv="clr-namespace:Preparation.Converters"
             xmlns:viewmodel="clr-namespace:Preparation.ViewModel"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="AppRevision.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

    </Application.Resources>
</Application>


AppRevision.xaml
C#
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:src="clr-namespace:Preparation.DataModel" 
             xmlns:conv="clr-namespace:Preparation.Converters"
             xmlns:viewmodel="clr-namespace:Preparation.ViewModel"
>

    <!-- <conv:DateConverter x:Key="dateConverter"/>
    <conv:IntToStringConverter x:Key="IntToOvenSeqMode" FalseValue="Hold"   TrueValue="Ramp" />-->

    <Style x:Key="titleStyle" TargetType="TextBlock">
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="Foreground" Value="DodgerBlue"/>
        <Setter Property="FontSize" Value="18"/>
    </Style>

    <DataTemplate DataType="{x:Type src:TableHandler}">
     ...
    </DataTemplate>
</ResourceDictionary> 


I can compile the project, but when starting it I get the following message at the DataType:
System.Windows.Markup.XamlParseException
InnerException: {"Type reference can't find any type with name {clr-namespace:Preparation.DataModel}TableHandler."}


If i don't comment out the DateConverter, I get a similar error there instead.

The odd thing is that it works when the code is inside app.xaml.
I guess that it's a simple error, but I haven't been able to find it.
Posted
Updated 7-Oct-14 1:21am
v2

1 solution

I found the error myself.
I have to specify the assembly also for some reason.
It wasn't required in app.xaml.

C#
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:src="clr-namespace:Preparation.DataModel;assembly=Preparation" 
             xmlns:conv="clr-namespace:Preparation.Converters;assembly=Preparation"
             xmlns:viewmodel="clr-namespace:Preparation.ViewModel;assembly=Preparation"
></resourcedictionary>


Maybe there is a setting somewhere else that I don't know about.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900