windows phone 7 - How to open a webbrowser inside a WP7 application , using a specific URL? -


i developing application , need 2 things :

1) use push notifications.

2) open specific url on startup.

i wrote push notification code inside mainpage , looks :

namespace windowspush {     public partial class mainpage : phoneapplicationpage     {         // constructor         public mainpage()         {             /// holds push channel created or found.             httpnotificationchannel pushchannel;              // name of our push channel.             string channelname = "toastsamplechannel";              initializecomponent();              // try find push channel.             pushchannel = httpnotificationchannel.find(channelname);              // if channel not found, create new connection push service.             if (pushchannel == null)             {                 pushchannel = new httpnotificationchannel(channelname);                  // register events before attempting open channel.                 pushchannel.channeluriupdated += new eventhandler<notificationchannelurieventargs>(pushchannel_channeluriupdated);                 pushchannel.erroroccurred += new eventhandler<notificationchannelerroreventargs>(pushchannel_erroroccurred);                  // register notification if need receive notifications while application running.                 //pushchannel.shelltoastnotificationreceived += new eventhandler<notificationeventargs>(pushchannel_shelltoastnotificationreceived);                  pushchannel.open();                  // bind new channel toast events.                 pushchannel.bindtoshelltoast();              }             else             {                 // channel open, register events.                 pushchannel.channeluriupdated += new eventhandler<notificationchannelurieventargs>(pushchannel_channeluriupdated);                 pushchannel.erroroccurred += new eventhandler<notificationchannelerroreventargs>(pushchannel_erroroccurred);                  // register notification if need receive notifications while application running.                 //pushchannel.shelltoastnotificationreceived += new eventhandler<notificationeventargs>(pushchannel_shelltoastnotificationreceived);                  // display uri testing purposes. normally, uri passed web service @ point.                 system.diagnostics.debug.writeline(pushchannel.channeluri.tostring());                 // messagebox.show(string.format("channel uri {0}", pushchannel.channeluri.tostring()));              }           }           void pushchannel_channeluriupdated(object sender, notificationchannelurieventargs e)         {             dispatcher.begininvoke(() =>             {                 // display new uri testing purposes.   normally, uri passed web service @ point.                 system.diagnostics.debug.writeline(e.channeluri.tostring());                 messagebox.show(string.format("channel uri {0}", e.channeluri.tostring()));             });         }           void pushchannel_erroroccurred(object sender, notificationchannelerroreventargs e)         {             // error handling logic particular application here.             dispatcher.begininvoke(() =>                 messagebox.show(string.format("a push notification {0} error occurred.  {1} ({2}) {3}", e.errortype, e.message, e.errorcode, e.erroradditionaldata)));         }       } } 

this code inside mainpage.xaml.cs . how open in here specific url ?

to open url in windows phone, there 2 approaches.

  • use webbrowsertask
  • use webbrowser control

    you can take either of above approaches display contents of url, per requirements.


  • Comments