GoTo
GoTo

Reputation: 6686

Error XDG0066 System.MissingMethodException: Method not found: 'Windows.UI.Xaml.XamlRoot Windows.UI.Xaml.UIElement.get_XamlRoot()'

I'm trying to follow this tutorial but I get an error on line:

<controls:DataGrid x:Name="dataGrid">

The error is:

XDG0066 System.MissingMethodException: Method not found: 'Windows.UI.Xaml.XamlRoot Windows.UI.Xaml.UIElement.get_XamlRoot()'.

ConvertPage.xaml:

<Page
    x:Class="MyApp.ConvertPage.ConvertPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <controls:DataGrid x:Name="dataGrid">  <--- line with error

        </controls:DataGrid>


    </Grid>
</Page>

ConvertPage.xaml.cs:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

namespace MyApp.ConvertPage
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class ConvertPage : Page
    {
        public ConvertPage()
        {
            this.InitializeComponent();
        }
    }
}

Microsoft.Toolkit.Uwp v7.1.2

Target: Universal Windows

Min and Target Version: 17763

enter image description here

enter image description here

Upvotes: 0

Views: 1567

Answers (1)

Roy Li - MSFT
Roy Li - MSFT

Reputation: 8666

I've checked this and I could reproduce this issue. The issue is caused by the Min and Target Version. When adding the nuget package into the project, it contains a warning saying Microsoft.UI.Xaml nuget package requires TargetPlatformVersion >= 10.0.18362.0 (current project is 17763).

Please change the Min and Target Version of your project to 18362 or higher and run your app again. It should solve the issue.

Upvotes: 1

Related Questions