Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown type 'AppBarButton' in XML namespace - Windows 8 Store App XAML, issues adding app bars

I'm new to developing Windows 8 apps, and am having trouble getting my XAML file to recognise generated code for adding AppBars and CommandBars.

I am getting the error "Unknown type [something] in XML namespace" for a number of elements I am trying to add, here is my example below:

Unknown type 'AppBarButton' in XML Namespace

If I re-open my solution this is temporarily displayed as a warning rather than an error. Also navigating to http://schemas.microsoft.com/winfx/2006/xaml/presentation just produces "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.".

This is all default code. my class namespace (e.g. MyApp.MainPage) matches the MainPage code behind namespace. I am at a loss and have been battling this for hours. I also intermittently changes from this error to 'InitializeComponent' does not exist in the current context". I have spent hours on XAML permissions errors in the past few days and don't want to waste any more time with errors in default generated code! :(

EDIT: I have tried this on three different machines, using both Windows 8 and Windows 8.1, both new projects and the existing project I have described in this post.

like image 825
Vixxd Avatar asked Nov 05 '13 23:11

Vixxd


1 Answers

My guess is that you are using Visual Studio 2012 (Windows 8 apps). If so, you should use Button:

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

To use AppBarButton, you must use Visual Studio 2013 (Windows 8.1 apps):

<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, CommandBars are only available in Windows 8.1.

like image 68
chue x Avatar answered Sep 29 '22 07:09

chue x