错误 XDG0066 System.MissingMethodException:找不到方法:'Windows.UI.Xaml.XamlRoot Windows.UI.Xaml.UIElement.get_XamlRoot()'
Error XDG0066 System.MissingMethodException: Method not found: 'Windows.UI.Xaml.XamlRoot Windows.UI.Xaml.UIElement.get_XamlRoot()'
我正在尝试遵循此 tutorial 但我在 行 :
上收到错误
<controls:DataGrid x:Name="dataGrid">
错误是:
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
目标:通用Windows
最低和目标版本:17763
我已经检查过了,我可以重现这个问题。该问题是由 最低和目标版本 引起的。将 nuget 包添加到项目中时,它包含一个警告说 Microsoft.UI.Xaml nuget package requires TargetPlatformVersion >= 10.0.18362.0 (current project is 17763)
。
请将项目的最低版本和目标版本更改为 18362 或更高版本,并再次 运行 您的应用。它应该可以解决问题。
我正在尝试遵循此 tutorial 但我在 行 :
上收到错误<controls:DataGrid x:Name="dataGrid">
错误是:
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
目标:通用Windows
最低和目标版本:17763
我已经检查过了,我可以重现这个问题。该问题是由 最低和目标版本 引起的。将 nuget 包添加到项目中时,它包含一个警告说 Microsoft.UI.Xaml nuget package requires TargetPlatformVersion >= 10.0.18362.0 (current project is 17763)
。
请将项目的最低版本和目标版本更改为 18362 或更高版本,并再次 运行 您的应用。它应该可以解决问题。