简体   繁体   English

在WebView Windows Phone 8.1中显示本地图像

[英]Show local images inside WebView windows phone 8.1

I am trying to load a html file in Webview in WP8.1 app. 我正在尝试在WP8.1应用程序的Webview中加载html文件。 I have the image stored inside my project. 我将图像存储在我的项目中。 When I run the html file in browser it runs properly but when I load this html file in Webview it does not show image and same thing happens when I convert the contents of HTML file in string and try the NavigateToString method. 当我在浏览器中运行html文件时,它可以正常运行,但是当我在Webview中加载该html文件时,它不显示图像,并且当我将HTML文件的内容转换为字符串并尝试使用NavigateToString方法时,也会发生同样的事情。 Here is my code 这是我的代码

<!DOCTYPE html>
   <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <meta charset="utf-8" />
      <title></title>
      <style>
        table, th, td {
            border: 0px;
        }
     </style>
    </head>
    <body>
    <table>
        <tr>
            <img src="ms-appx:///discount_icon.jpg" alt="Smiley face" height="200" width="400" />
        </tr>
        <tr>
            <td>
                        <div align="Left" style="width: 100%;">
                            <div style="width: 70%; float: left;"><b> Left </b>    </div>

                            <div align="right" style="width: 30%; float: right;">
                                <div align="right" style="position: relative;  padding-top:10px; background-image: url('ms-appx:///discount_icon.jpg');background-size:cover; background-repeat:no-repeat; height:36px; width: 85px; font-weight: bold; color: black;"><span style="text-align:center;color:white; margin-right:27px;margin-top:15px">5%</span></div>
                            </div>

                            <div style="width: 70%; float: left;"> From <span style="background-color:#01A9DB;padding:2px;">$250.00</span> values </div>

                        </div>
           </td>
        </tr>
        <tr>
            <td>February</td>
        </tr>
    </table>
     </body>
    </html>

Can somebody help? 有人可以帮忙吗?

You don't need to put ms-appx:/// before the image name in the source of the html image. 您无需将ms-appx:///放在html图像源中的图像名称之前。

If you have the image in the same folder of the html, the code would be like this: 如果图像位于html的同一文件夹中,则代码将如下所示:

<img src="test.png" style="width:100%; height:100%;" />

You can try NavigateToLocalStreamUri . 您可以尝试NavigateToLocalStreamUri You can google it. 你可以谷歌。 There are a lot of examples about that function. 关于该功能有很多示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM