6

I create new Uno Cross-Platform App 2.2 from template. When I open Shared->MainPage.xaml in doesn't open designer in code view there is a underlined error The type 'page' does not support direct content

<Page
    x:Class="App6.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App6"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <TextBlock Text="Hello, world!" Margin="20" FontSize="30" />
    </Grid>
</Page>
Matevz
  • 71
  • 1
  • 3

3 Answers3

12

This is an Intellisense issue which happens when the project selector (the DropDown at the top of the XAML editor) is not on the UWP project, but rather on iOS, Android or another platform.

If you select the UWP project, close the editor, and re-open it again, the errors will disappear.

As of Visual Studio 2019 16.5 the issue is still present, but is likely to be addressed in a future version.

Jérôme Laban
  • 5,224
  • 3
  • 20
  • 17
  • In the C# file behind the XAML, I was never able to get the project selector to stay on the UWP project. I could select every other project but that one. It would swap back to the most recent selection if I clicked away from the dropdown box. For the XAML file, I couldn't even get the dropdown to appear at all. All I got was a blank tab unless I opened the file in the XAML Text Editor instead. – catherinemohan Dec 08 '20 at 05:04
1

At the beginning I can use designer to edit MainPage.xaml in Shared folder, after one moment (there was an error that crashed my VS) not any more...

So solution is to move MainPage.xml to UWP project, edit there, and than move it back. That's work for now.

Maybe it would work with linked file.

Matevz
  • 71
  • 1
  • 3
0

I used Blend for Visual Studio to open and edit the file. The next time I opened the project with VS the problem was fixed.