Images from Assets Folder are not working in UWP app

怎甘沉沦 提交于 2019-12-08 16:45:26

问题


The Images are working in the MainPage, but I'm trying to Integrate it in an Navigational Panel Templete and the images don't show up. Can anyone suggest me what might be the problems.

The Templete's making use of FRAMES but that should not be the issues.

XAML code

<Button Grid.Column="0" Style="{StaticResource NavigationButtonStyle}">
                <StackPanel Orientation="Horizontal">
                    <Image Source="Assets/donut-icon.png" Style="{StaticResource IconImageStyle}" />
                    <TextBlock Text="Donut" Foreground="White" />
                </StackPanel>
            </Button>

Styles Resources

 <Style TargetType="Image" x:Key="IconImageStyle">
            <Setter Property="Height" Value="20" />
            <Setter Property="Width" Value="20" />
            <Setter Property="Margin" Value="0,0,10,0" />
        </Style>

回答1:


I noticed that your page is in your "Pages/Go Nuts" folder, so you should use following URI to get the image.

<Image Source="ms-appx:///Assets/donut-icon.png" />

Or

<Image Source="/Assets/donut-icon.png" />

While using <Image Source="Assets/donut-icon.png" /> it will search resource in current folder. But there is no such resource in current folder, so it won't work.



来源:https://stackoverflow.com/questions/33516523/images-from-assets-folder-are-not-working-in-uwp-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!