Search code examples
.netvisual-studioxamarinxamarin-zebblezebble

How can I show a web page in a mobile device with web view in Zebble for Xamarin?


I have tried to follow the documentation here:

http://zebble.net/docs/webview-class-displaying-html

I make a web page and try to show it in the device from local folder, for this I found a sample code from Zebble.net website to show the web page in the device. I try to show the page with this code below.

<WebView Url="Resources/index.html" />

But, it is shows this error: File not found: /Resources/index.html

Then I change it to code below, but again it did not work.

<WebView Url="/Resources/index.html" ></WebView>

Solution

  • To show a local html file inside a WebView in Zebble, you do not need to write "resources" in the URL. Although the file is inside the Resources folder, but you should omit that part as it's implied.

    See http://zebble.net/docs/accessing-files-and-folders

    The following code will show a HTML File named index.html inside your App.UI\Resources folder:

    <WebView Url="/index.html">
    

    Here is the code for a full Zebble page to test it:

    <z-Component z-type="MyPage" z-base="Templates.Default" 
         z-namespace="UI.Pages"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="./../.zebble-schema.xml">
    
           <WebView Url="/index.html" />
    
    </z-Component>