XAML 在Visual Studio for Mac中找不到型别'StackPanel'

tf7tbtn2  于 2022-12-07  发布在  Mac
关注(0)|答案(1)|浏览(152)

代码的照片:The error: ContentPage
Cs file
Xaml file
another css file
我是Visual Studio for Mac的新手(在这里构建我的第一个项目)。到目前为止一切都很顺利,但当我试图使用<StackPanel> </StackPanel>时-我遇到了一个问题。带有红色下划线,我收到了一个错误:〈未找到类型“StackPanel”。请验证您没有缺少程序集引用,并且所有引用的程序集都已构建。〉
其他信息:文件格式:File.xaml
您能指出我应该安装哪个程序集或软件包来消 debugging 误吗?并且指定执行您的指令的方式。

alen0pnh

alen0pnh1#

StackPanel could not be found (missing assembly reference)
不完全确定,但可以尝试在项目引用中添加PresentationFramework引用

如果这对阅读这篇文章没有帮助,请发表评论:The type was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built
尝试在代码中添加引用,如下所示

<Window x:Class="YourClassName"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="StackPanel" Height="160" Width="300">

部分链接:
https://www.infragistics.com/help/wpf/adding-assembly-to-a-visual-studio-project
https://wpf-tutorial.com/panels/stackpanel/
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/xaml-namespaces-and-namespace-mapping-for-wpf-xaml?view=netframeworkdesktop-4.8
希望这些可以帮助解释多一点

相关问题