XML 命名空间中的未知类型“AppBarButton” - Windows 8 Store App XAML,添加应用栏时出现问题

2023-12-30

我是开发 Windows 8 应用程序的新手,并且无法让我的 XAML 文件识别用于添加 AppBar 和 CommandBar 的生成代码。

对于我尝试添加的许多元素,我收到错误“XML 命名空间中的未知类型 [某物]”,下面是我的示例:

如果我重新打开我的解决方案,这会暂时显示为警告而不是错误。还导航至http://schemas.microsoft.com/winfx/2006/xaml/presentation http://schemas.microsoft.com/winfx/2006/xaml/presentation只是产生“您正在查找的资源已被删除、名称已更改或暂时不可用。”。

这都是默认代码。我的类命名空间(例如 MyApp.MainPage)与命名空间后面的 MainPage 代码匹配。我很茫然,已经为此奋斗了几个小时。我还间歇性地从此错误更改为“InitializeComponent”在当前上下文中不存在”。过去几天我在 XAML 权限错误上花费了数小时,并且不想再浪费时间在默认生成的代码中的错误上! :(

编辑:我已经在三台不同的机器上尝试过此操作,使用 Windows 8 和 Windows 8.1,新项目和我在这篇文章中描述的现有项目。


我的猜测是您使用的是 Visual Studio 2012(Windows 8 应用程序)。如果是这样,你应该使用Button http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.button.aspx:

<Page.TopAppBar>
    <AppBar>
        <StackPanel Orientation="Horizontal">
            <Button Style="{StaticResource AppBarButtonStyle}">A</Button>
            <Button Style="{StaticResource AppBarButtonStyle}">B</Button>
        </StackPanel>
    </AppBar>
</Page.TopAppBar>

To use 应用栏按钮 http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.appbarbutton.aspx,您必须使用 Visual Studio 2013(Windows 8.1 应用程序):

<Page.TopAppBar>
    <AppBar>
        <StackPanel Orientation="Horizontal">
            <AppBarButton>
                <AppBarButton.Icon>
                    <FontIcon Glyph="A"/>
                </AppBarButton.Icon>
            </AppBarButton>
            <AppBarButton>
                <AppBarButton.Icon>
                    <FontIcon Glyph="B"/>
                </AppBarButton.Icon>
            </AppBarButton>
        </StackPanel>
    </AppBar>
</Page.TopAppBar>

Also, 命令栏 http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.commandbar.aspx仅在 Windows 8.1 中可用。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

XML 命名空间中的未知类型“AppBarButton” - Windows 8 Store App XAML,添加应用栏时出现问题 的相关文章

随机推荐