4

I have created hybrid app in Windows phone 8.1

One of my pages uses the webview control.

It has an img element on it.

I have a small image as part of the build of my application. The 'copy to Output Directory' is set to 'Copy always'

I have followed the instructions from this page: enter link description here

None of the samples work.

If I could assign that image in my c# code then that would be another alternative to use?

I would need to know how to get the absolute path of my image in my solutions and then get the ID from the webview?

I am guessing here.

Can this be done?

ADDITIONAL:

My html on aspx page on my server

<img src="/Images/eyeon.png" />

I added the eyeon.png image to my C# solution.

Andrew Simpson
  • 6,883
  • 11
  • 79
  • 179
  • You have *Image* over *WebView* or you want to show image in *WebView*. Can you show some code? – Romasz Nov 27 '14 at 09:56
  • Hi, thanks for the interest. I will edit my question now – Andrew Simpson Nov 27 '14 at 09:58
  • 1
    If I understand correct: you have a WebView, that displays html file from server and in that html you have an Image which should be taken from the App.Package? I'm not sure, but try: ``, check if your image has BuildAction set to Content. I'm not sure if that will work. – Romasz Nov 27 '14 at 10:06
  • Hi again. Yes, I have tried that and it did not work. That was why I was considering setting it in C# via the native app :( – Andrew Simpson Nov 27 '14 at 10:08
  • 1
    Can you debug and see what html file the *WebView* recieves? – Romasz Nov 27 '14 at 10:11
  • Hi, thanks for your continued assistance. I am not sure how to do that? I cannot view source of the control via the emulator..? – Andrew Simpson Nov 27 '14 at 10:13
  • I have found out to debug. Quite a cool feature i will look at it now.. – Andrew Simpson Nov 27 '14 at 10:24
  • Hi, the HTMl shows: – Andrew Simpson Nov 27 '14 at 10:29
  • with thismessage:SEC7117: Network request to http://www.informedmotion.co.uk/NativeApp/'ms-appx:///Images/eyeon.png did not succeed. – Andrew Simpson Nov 27 '14 at 10:29
  • I do not know if this message islinked: Your application manifest does not declare the following capabilities: internetClient privateNetworkClientServer – Andrew Simpson Nov 27 '14 at 10:31
  • Yeah, debug is a nice feature ;) As it shows it tries to look for your image on your server. – Romasz Nov 27 '14 at 10:31
  • I'm not sure if you will be able to mix sources of content (app and webserver). You may take a look at this two threads: [one](https://social.msdn.microsoft.com/Forums/windowsapps/en-US/8dba4472-e224-4000-a016-7ee2be9c450f/how-to-create-a-webview-accessible-locally-created-image-file?forum=winappswithcsharp) and [two](https://social.msdn.microsoft.com/Forums/windowsapps/en-US/08b9b639-aaa8-41c9-bddf-204098c485ac/webview-does-not-load-msappxweb-contents-onto-https-page?forum=winappswithcsharp), maybe they will help little. – Romasz Nov 27 '14 at 10:38
  • Hi, thanks for that. Worth exploring :) – Andrew Simpson Nov 27 '14 at 10:39

1 Answers1

4

For anyone following this, this worked for me:

src = "ms-appx-web:///Images/NoFeed.jpg"
halfer
  • 19,824
  • 17
  • 99
  • 186
Andrew Simpson
  • 6,883
  • 11
  • 79
  • 179