gpt4 book ai didi

c# - 错误 XDG0008 : NumberBox is not supported in a Universal Windows Platform project

转载 作者:行者123 更新时间:2023-12-02 16:47:27 27 4
gpt4 key购买 nike

下面的代码有一个奇怪的问题:

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

<Grid>
<NumberBox x:Name="BeginNumberBox"
Header="Enter an integer:"
Value="1"
SpinButtonPlacementMode="Compact"
SmallChange="10"
LargeChange="100"/>
</Grid>
</Page>

IDE Screenshot

创建项目后,在我添加 <NumberBox> 之前没有进行任何更改.会出现三个编译错误:

Error message

我尝试更新 NuGet 包:

NuGet Package Manager

但是错误依旧。

我该如何修复?

我真的需要一些帮助:/


开发环境:

  • IDE:Visual Studio 2019

    UWP项目目标版本:Windows 10,版本1903(10.0; Build18362)

    UWP 项目最低版本:Windows 10,版本 1903(10.0;Build 18362)

最佳答案

从这里document NumberBox,可以看到NumberBox在Microsoft.UI.Xaml.Controls命名空间下,适用于WinUI。正如@magicandre1981 所说,您需要安装 Microsoft.UI.Xaml nuget 包并将 Windows UI (WinUI) 主题资源添加到您的 App.xaml 资源。然后在xaml中添加命名空间即可使用。

应用程序.xaml:

<Application ...>
<Application.Resources>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
</Application.Resources>
</Application>

.xaml:

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

<Grid>
<controls:NumberBox x:Name="BeginNumberBox"
Header="Enter an integer:"
Value="1"
SpinButtonPlacementMode="Compact"
SmallChange="10"
LargeChange="100"/>
</Grid>
</Page>

关于c# - 错误 XDG0008 : NumberBox is not supported in a Universal Windows Platform project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59932074/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com