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.

(113) Comments

Blog Message http://www.fofti.com/fofti/member.php?u=44456

Thanks a lot for the blog post.Much thanks again. Cool.


Blog Message https://speakerdeck.com/tiphivigex

What kind of camera was used? That is definitely a really good superior quality.


Blog Message https://www.bulkbuyaccs.com/buy-instagram-accounts/

Thanks a lot for the article.Really looking forward to read more. Great.


Blog Message http://gprovmods.com/index.php/component/k2/itemlist/user/325760

Really clear internet site, thanks for this post.


Blog Message http://mediawiki.djazair.site/index.php?title=User:BIZSherryl

Very couple of internet sites that occur to become in depth below, from our point of view are undoubtedly well worth checking out.


Blog Message http://test.ccfmoldova.org/?option=com_k2&view=itemlist&task=user&id=48232

Wow! Thank you! I permanently wanted to write on my site something like that. Can I implement a fragment of your post to my website?


Blog Message https://wallinside.com/post-63365424-3-ulterior-motives-to-invest-in-qualified-professional-landscape-designs-services-perth.html

Wow! This can be one particular of the most useful blogs We ave ever arrive across on this subject. Actually Magnificent. I am also an expert in this topic so I can understand your effort.


Blog Message https://youtu.be/CHgr_AdllRs

Thanks so much for the blog post.Thanks Again. Keep writing.


Blog Message https://www.scribd.com/user/388522596/erconforlurz4

I was recommended this web site by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my difficulty. You are wonderful! Thanks!


Blog Message https://www.enigmaglobal.com/by-country-media-selection/

Enjoyed every bit of your article.Much thanks again. Really Cool.


Blog Message https://www.youtube.com/watch?v=Nki0NHQVw_8

Thanks a lot for the article post.Really thank you! Cool.


Blog Message https://budhubexpress.ca/

This site definitely has all the information and


Blog Message http://tacticalbootsdirect.com/under-armour-tactical-boots/

With this increased targeted visitors movement, the opportunity to increase income raises as well.


Blog Message https://www.plurk.com/p/ml9ouj

pretty handy stuff, overall I think this is well worth a bookmark, thanks


Blog Message http://sattamatkamarket.org

I truly enjoy looking through on this internet site, it holds excellent content. Beware lest in your anxiety to avoid war you obtain a master. by Demosthenes.

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