I have a WPF solution built with VS 2015 composed of several projects. Suddenly I started receiving a warning in design mode stating the following:
The t
Make sure you reference System.Xaml. Clean and rebuild the project. Works on VS 2015 Update 1.
on behalf of @mark Richman I edited the Itemtemplate to automatically Reference "System.Xaml". Just in case some is interested:
can be found in: "[VS InstallDir]\Common7\IDE\ItemTemplates\VisualBasic\WPF\[InputLocale]\WPFWindow"
BR, Daniel
At least in a WPF IronPython project, adding the System.Xaml
reference to the project solved the problem for me:
An important thing to note here is that adding seemingly any reference will make the problem go away temporarily -- until Visual Studio is restarted. System.Xaml
, on the other hand, appears to keep the problem at bay. I even tried removing the reference, whereafter the problem returned upon restarting Visual Studio.
Add System.Xaml and UIAutomationProvider references to your project, after that clear solution and then build again
For me this error was happening because I added a WPF Window to a class library project.
For some reason (unknown by me), Visual Studio doesn't give us the option to select the WPF Window template from the "Add New Item..." dialog box if the project was not created as a WPF Application. Instead, it only offers the option to add a WPF User Control. Because of that, I selected the User Control template for the new item, and then edited the source code to make the XAML to become a Window object rather than a User Control.
<!-- The new item was created as an UserControl, but what I needed was a Window object. -->
<UserControl>
...
</UserControl>
<!-- Changed it to Window and made other necessary adjustments. -->
<Window>
...
</Window>
The problem was actually in the code-behind. Since it was created as an User Control, the window partial class was inheriting from UserControl, like the following:
public partial class MyWindow : UserControl
{
public MyWindow ()
{
InitializeComponent();
}
}
To fix it I just had to remove the inheritance, making my window class inherith from nothing, like this:
public partial class MyWindow
{
public MyWindow ()
{
InitializeComponent();
}
}
After removing the inheritance, Visual Studio didn't show the error "The type 'Window' does not support direct content." anymore.