How to use the webView feature in visual studio (C#) RRS feed

  • Question

  • Hi, how can I use the webview Tool in C# in visual studio to create a windows 8.1 app (A simple web browser). I have tried these code and both of these don't work. I have worked with Visual Basic but am trying to move on to C#. I have tried these but none have worked in C#, please can someone help me out. Thanks.

    Tried this, but didn't work

          private void Page_Loaded(object sender, RoutedEventArgs e)
    Also, tried these, which didn't work either

           private void Page_Loaded(object sender, RoutedEventArgs e)
                  Webview1.Navigate(New Uri(http://www.bing.com));
    Am I doing somethig wrong or is this code not for Visual Studio C#.

    Thanks in advance.
    Sunday, October 12, 2014 8:41 AM


All replies

  • Hi,

    The Navigate method takes a Uri as parameter. And the New Uri construtor takes an string as parameter.


    So it should be:

    WebView1.Navigate(new Uri(@"http://www.bing.com"));

    • Proposed as answer by ChervineMVP Sunday, October 12, 2014 10:18 AM
    • Marked as answer by Hilbis White Monday, October 13, 2014 5:05 AM
    Sunday, October 12, 2014 9:07 AM
  • Hi, thanks, it works!! I have few more questions, please could you help me out?

    1. Is there a fast way to comment out codes, e.g. in java we can press 'ctrl' and '/' to comment codes, is there similar keyboard shortcut for VB C#

    2. Say for example, I allow my users to type in a website on a textbox for the webview to nevigate to, is it possible to keep that website address saved, so next time when the user opens the app, it automatically opens that website address rather then asking the user to type it in again.

    3. Is it possible to allow the user to type in the website address in any format, such as.





    Thanks once again.

    Sunday, October 12, 2014 9:39 AM
  • Hi,

    Please mark the previous reply as answer.

    Replies to your additional questions below:

    1. Comment codes in visual studio : CTL+ E + C

        Un-comment codes visual studio : CTL+ E + U

    2. Save the last visited Uri and retrieve it when the user open the App again.

    You may use Local App Data to save the Uri


    3. Not putting the Uri in the correct format will throw a System.UriFormatException

        You may write some codes to format the Uri to the correct format.

    • Edited by ChervineMVP Sunday, October 12, 2014 11:13 AM
    Sunday, October 12, 2014 10:17 AM
  • Hi, I have marked the reply as answer and thanks for asking my other questions. Is there any tutorial (preferably video tutorial) to guide on how to use local app data, I am new to C# and have no idea how to go about start using local app data. 

    Monday, October 13, 2014 5:13 AM
  • Monday, October 13, 2014 5:24 PM