I have a class, partially defined in XAML and partially in code:
The file ElementResource.xaml looks like this:
<ResourceDictionary x:Class="TestElement.Views.ElementResource"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TestElement.Views"
xmlns:vm="clr-namespace:TestElement.ViewModels">
<DataTemplate x:Key="TestTemplate" DataType="{x:Type vm:TestElementViewModel1}">
</DataTemplate>
</ResourceDictionary>
The rest of the class *ElementResource" is defined in code in the file ElementResource.xaml.cs like this:
using System.ComponentModel.Composition;
using System.Windows;
namespace TestElement.Views
{
[Export(typeof(ResourceDictionary))]
public partial class ElementResource : ResourceDictionary
{
}
}
For some reason, the class part defined in XAML is not recognized in the "code-behind":
Also, the DataTemplate defined in XAML is not contained in the resource dictionary after initialization.
I've tried building and rebuilding, Ctrl+Shift+s and double-checked the requirements for partial classes here.
What am I missing??
Ok, I got it: I copied and pasted the xaml file from another project and on pasting the file to the current project, it's BuildAction property changed to none which I didn't notice... Swithcing it to Page makes the xaml part known...
Thanks for your help, everybody!