6

I know a variant of this question has been asked before but none of the answers there work in my case (and I'm not sure if the other user could actually compile or not)

I create a brand new WPF UserControl file. Visual Studio now displays blue lines around the <Grid></Grid> with this error:

The type 'UserControl' does not support direct content

My project already has references to System.Xaml and UIAutomationProvider, as well as the other WPF assemblies PresentationCore, PresentationFramework and WindowsBase.

If I build the solution the error goes away. If I then make a single change to the XAML file (like adding a space somewhere) the error returns.

This is extremely annoying as my entire XAML file ends up being underlined by Visual Studio as having an error and makes it hard to read the contents, when in reality it does not actually have any errors.

What can be done to remedy this situation?

3
  • 1
    Have you tried restarting Visual Studio/the computer? The designer can be buggy sometimes. Commented Aug 18, 2016 at 11:16
  • A restart of Visual Studio did actually help in this case, but I do remember the error appearing quite immediately after a VS/PC restart earlier this week, so something is still up with VS. If it's a known bug that can't be remedied by the user then this question can be closed. I'll leave it open if it is something that can be fixed locally. Commented Aug 18, 2016 at 11:37
  • Odd error, odd fix, but yes, a VS restart did the trick. Commented Sep 8, 2016 at 0:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.