[WP8.1] AppBarButton.Icon未在CommandBar中正确显示 [英] [WP8.1]AppBarButton.Icon is not correctly displayed in CommandBar

查看:52
本文介绍了[WP8.1] AppBarButton.Icon未在CommandBar中正确显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Visual Studio Express 2013将Windows 8.1应用程序移植到Windows Phone 8.1。我们在Page.BottomAppBar.CommandBar中为AppBarButton.Icon使用自定义的.png 图像。这是XAML代码:

We're porting a Windows 8.1 app to Windows Phone 8.1 with Visual Studio Express 2013. We use customized .png images for AppBarButton.Icon in Page.BottomAppBar.CommandBar. Here is the XAML code:

    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton>
                <AppBarButton.Icon>
                    <BitmapIcon UriSource="Assets/Information.png"/>
                </AppBarButton.Icon>
            </AppBarButton>
            <AppBarButton>
                <AppBarButton.Icon>
                    <BitmapIcon UriSource="Assets/3D.png"/>
                </AppBarButton.Icon>
            </AppBarButton>
            <AppBarButton>
                <AppBarButton.Icon>
                    <BitmapIcon UriSource="Assets/Home.png"/>
                </AppBarButton.Icon>
            </AppBarButton>            
            <AppBarButton>
                <AppBarButton.Icon>
                    <BitmapIcon UriSource="Assets/Preferences.png"/>
                </AppBarButton.Icon>
            </AppBarButton>
        </CommandBar>
    </Page.BottomAppBar>

显示结果如下所示。请注意左边的第二个按钮(红色方块)

The display result is shown below. Note that the second button (squared in red) from the left

原始图片是

图像在AppBar(Windows 8.1应用程序)中显示正常,略有不同XAML语法

The image is displayed fine in AppBar (Windows 8.1 app) with a slightly different XAML syntax

    <Button x:Uid="AppBar_Dimension"
        BorderThickness="0" Background="#FF000000" Height="100" Width="100">
        <Image Source="Assets/3D.png"/-->                        
    </Button>

任何人都可以提供帮助,谢谢!

Could anyone help, thanks!

推荐答案

尝试使用ContentTemplate显示图像:

Try to use a ContentTemplate to display the Image:

<AppBarButton>
                <AppBarButton.ContentTemplate>
                    <DataTemplate>
                        <Image Source="Assets/3D.png" />
                    </DataTemplate>
                </AppBarButton.ContentTemplate>
            </AppBarButton>



有关更多信息,请参阅以下主题:< a href ="https://social.msdn.microsoft.com/Forums/en-US/dec02456-4d47-4e5e-9a0c-bbb0da2fb582/how-to-create-add-custom-icons-to-windows-app- bar-?forum = winappswithcsharp">
https://social.msdn.microsoft.com/Forums/en-US/dec02456-4d47-4e5e-9a0c-bbb0da2fb582/how-to-create-add-custom- icons-to-windows-app-bar-?forum = winappswithcsharp

希望有所帮助。

请记得关闭你的主题将有用的帖子标记为答案,然后在有新问题时开始新的帖子。请不要在同一个帖子中提出几个问题。

Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.


这篇关于[WP8.1] AppBarButton.Icon未在CommandBar中正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆