News
  • Favorite
  • Facebook
  • Twitter
  • LinkedIn

Microsoft Press Pearson Education (InformIT)
Skip Navigation Links
Pearson Education (InformIT)
How to: Navigate to a web page from Windows 8 Store App Settings Flyout

Sometimes you have a Windows Store Application and you want the user to write a feedback using a form in your website. In this article we will create a Windows Store Application that implements the settings contract and create an entry in the settings flyout that opens your website feedback.

Create a Blank Windows Store App

1.      Open Visual Studio 2012 for Windows 8.

2.      Click on New Project. The New Project Dialog box appears.

3.      From the left pane select C# and then Windows Store Templates.

4.      From the right pane select Grid App Template.

5.      Type your project name and then click Ok. We set the project name to SettingsApp.

Create a new Windows Store App

Create the UI and adding Code

1.      Open the MainPage.xaml.cs file by double clicking the MainPage.xaml file from the Solution Explorer.

2.      Select the XAML view and find the Grid Control in the MainPage.xaml.

3.      Add the following namespaces to the start of the MainPage.xaml.cs file.

using Windows.UI.ApplicationSettings;

4.      Find the MainPage Constructor method and add the following code to it after the call to InitializeComponent method:

 

public MainPage()

{

    this.InitializeComponent();

 

    SettingsPane.GetForCurrentView().CommandsRequested += MainPage_CommandsRequested;

}

 

a.      The above code simply add a handler to the CommandsRequested Event. The CommandsRequestedevent occurs when the user opens the settings pane. Listening for this event lets the app initialize the setting commands and pause its UI until the user closes the pane.

b.     During this event, we will append our SettingsCommand objects to the available ApplicationCommands vector to make them available to the SettingsPane UI.

 

5.      After the MainPage Constructor method add the following code that will run when the CommandsRequested event fires.

 

private void MainPage_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)

{

    SettingsCommand feedbackCommand = new SettingsCommand("Feedback", "Feedback (web)", async (x) =>

    {

        Uri feedbackUri = new Uri("http://www.ultradevelopers.net/Feedback.aspx", UriKind.Absolute);

        await Launcher.LaunchUriAsync(feedbackUri);

    });

 

    args.Request.ApplicationCommands.Clear();

    args.Request.ApplicationCommands.Add(feedbackCommand);

}

a.      In the above code we simply create an object of the SettingsCommand class. The SettingsCommandcreates a settings command object that represents a settings entry. This settings command can be appended to the ApplicationCommands vector.

b.     We set the SettingsCommandobject Id to Feedback.

c.       Set the SettingsCommand Text to feed (web). It is recommended from the UX to indicate that the user will open a web page. If going directly to the web instead of a Flyout, let the user know with a visual clue, for example, "Help (online)" or "Web forums" styled as a hyperlink.

d.     Add a handler for the event that is raised when the user selects the command.

e.     In the command handler we create an object from the Uri class. The Uri class parses Uniform Resource Identifiers (URIs). Pass your Feedback page url to the Uri constructor and the type of that url. We set it as absolute.

f.       Then we call the Launcher.LaunchUriAsync async method. The Launcher class starts the default app associated with the specified file or URI.

g.      As we will open a web page so we use the LaunchUriAsync method and pass to it the Uri we have created.

h.     You have to use the await operator with any async methods. And mark the settingsCommand handler as async using the async keyword.

i.        Then we clear the ApplicationCommandsvector and add our feedback Settings Command.

6.      Build your project and run the project in Simulator.

7.      Open the Settings charm. You will find two commands. The feedback command and a system added command for Permission.

Windows Store App Settings

8.      Click on the Feedback (web) settings command this will launch the Internet Explorer with your website feedback page.

Windows Store App Settings

Now you have a Windows Store Application that implements the settings contract and create an entry in the settings flyout that opens your website feedback.

(62) Comments

Blog Message http://bayern.ge/user/DulcieBruns/

Very good article post.Really looking forward to read more. Keep writing.


Blog Message https://www.google.com/maps/place/Fast+Credit+Repair/@40.183011,-111.6099725,15z/data=!4m5!3m4!1s0x0:0xbec847bdb5016a70!8m2!3d40.183011!4d-111.6099725

Very good blog post. I definitely appreciate this site. Continue the good work!


Blog Message http://www.seoinvancouver.com/

Major thanks for the blog.Much thanks again. Really Great.


Blog Message http://www.witwebcoder.com/blog/perfect-spot-uncover-totally-free-ads-line

Spot on with this write-up, I absolutely feel this web site needs a


Blog Message https://twitter.com/kencalhoun

pretty useful material, overall I consider this is worthy of a bookmark, thanks


Blog Message http://blagovest-vlg.ru/bitrix/rk.php?goto=http://allelinks.dk/story.php?title=Buy-instagram-Followers

Very neat article.Really thank you! Really Cool.


Blog Message http://pinoyblog.wap.mu/redirect.php?url=http://www.gigasize.com/get/dvmp53ovy0d

there right now. (from what I ave read) Is that what you are using on your


Blog Message http://betterimagepropertyservices.ca/

you made running a blog glance easy. The total glance of


Blog Message https://www.crunchbase.com/organization/vip-financing-solutions

I truly enjoy studying on this site, it contains excellent blog posts. Don at put too fine a point to your wit for fear it should get blunted. by Miguel de Cervantes.


Blog Message http://www.ic.gc.ca/app/ccc/srch/nvgt.do;jsessionid=0001Tk8H4d3aGhRcFTiEBzCBug6:-GBDQLN?lang=eng&prtl=1&sbPrtl=&estblmntNo=234567159791&profile=cmpltPrfl&profileId=1461&app=sold&searchNav=F

Thanks for sharing, this is a fantastic blog article. Really Great.


Blog Message http://bit.ly/Como-Tener-una-ereccion

PlаА аЂа•аА аЂаse let me know where аАааБТ“ou got your thаА аЂа•mаА аЂа•.


Blog Message http://www.augencentrum.com

Thanks again for the post.Really looking forward to read more. Much obliged.


Blog Message http://iseecams.com/external_link/?url=http://design-buzz.com/story.php?title=more-information-8

That is a really good tip particularly to those fresh to the blogosphere. Brief but very precise information Thank you for sharing this one. A must read article!


Blog Message https://youtu.be/9I62Fkf7iO8

Really informative blog post.Thanks Again. Awesome.


Blog Message https://www.mystorethrift.com/blog

Incredible points. Outstanding arguments. Keep up the amazing effort.

First Previous 1 2 3 4 5 Next Last 
Rating
Name
Email
Comment