locked
How to use WebView to show local sites from JavaScript/HTML project ? Windows 8.1 RT

    Question

  • Hi.

    I have a sample project with JavaScript/HTML in here : https://msdn.microsoft.com/en-us/library/windows/apps/jj663502.aspx

    Now i create project with C#.

    - Replace reference to //Microsoft.WinJS.2.0/ with my WinJS download from original source. Sample still work correctly.

    - I copy all source code from above sample to this project.

    - In MainPage.xaml : i add a WebView.

    - In MainPage.xaml.cs : i navigate webview to default.html.

    But it's not run correctly. I don't know why ? Please explain for me and How to do it right ?

    I can't upload file to network. So sorry.

    Friday, March 06, 2015 12:33 PM

Answers

  • Hi Khiem,

    No. WinJS and C# WinRT project are two different implementations of metro style app development. There is no options to convert WinJS project to C# WinRT project besides manually porting it. Fortunately, you can easily find the similar API in C# WinRT project.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 09, 2015 8:02 AM
    Moderator

All replies

  • Hi Khiem,

    It seems that you want to host the WinJS project in WebView control, is that right? If not, feel free to let me know.

    Based on my knowledge, you cannot do this. WinJS project and C# store app project are different. WinJS project works on Windows Library for JavaScript 2.0, but there is no option to add this reference in C# windows store app project.

    Webview control is not a general- purpose browser, it’s not recommend to render this kind of content in it. Matt has a blog about the control. http://blogs.msdn.com/b/wsdevsol/archive/2012/10/18/nine-things-you-need-to-know-about-webview.aspx.

    Please post more information about your scenario on why you need host WinJS in WebView control.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 09, 2015 3:08 AM
    Moderator
  • Hi Herro wong

    I have a WinJS project and i want port it to C#. But project too large and hard to read and port to C# so i want to use a WebView in C# show content of WinJS.

    Begin i start with above sample. I hope i work and i will do for my project.

    Can you suggest for my some work around for this ?

    Thanks.

    Monday, March 09, 2015 3:31 AM
  • Hi Khiem,

    No. WinJS and C# WinRT project are two different implementations of metro style app development. There is no options to convert WinJS project to C# WinRT project besides manually porting it. Fortunately, you can easily find the similar API in C# WinRT project.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 09, 2015 8:02 AM
    Moderator