DZone
Mobile Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Mobile Zone > How to: Change the Start Page of a Windows 8 App in Visual Studio 2012

How to: Change the Start Page of a Windows 8 App in Visual Studio 2012

Senthil Kumar user avatar by
Senthil Kumar
·
Sep. 03, 12 · Mobile Zone · Interview
Like (0)
Save
Tweet
14.93K Views

Join the DZone community and get the full member experience.

Join For Free

when you create a new modern ui(metro) windows 8 project in visual studio , a default start page mainpage.xaml will be created automatically along with other necessary files needed for running the windows 8 app.

if you want to change the default start page of the windows 8 app from mainpage.xaml to another file for example (firstpage.xaml) , you can do that by following the below steps.

the app.xaml.cs has the onlaunched event where the initial start page is defined . by default , the mainpage is included .

how to change the start page of the windows 8 app in visual studio 2012 ?

how to change the start page of the windows 8 app in visual studio 2012 ?

you can create a new blank xaml page and replace “mainpage” with the newly create page name . for example , if your new pagename is firstpage.xaml , then replace mainpage with the firstpage like the way shown in the below sourcecode sample.

// invoked when the application is launched normally by the end user.  other entry points
// will be used when the application is launched to open a specific file, to display
// search results, and so forth.
//details about the launch request and process.
protected override void onlaunched(launchactivatedeventargs args)
{
            // do not repeat app initialization when already running, just ensure that
            // the window is active
            if (args.previousexecutionstate == applicationexecutionstate.running)
            {
                window.current.activate();
                return;
            }

            if (args.previousexecutionstate == applicationexecutionstate.terminated)
            {
                //todo: load state from previously suspended application
            }

            // create a frame to act navigation context and navigate to the first page
            var rootframe = new frame();
            if (!rootframe.navigate(typeof(firstpage)))
            {
                throw new exception("failed to create initial page");
            }

            // place the frame in the current window and ensure that it is active
            window.current.content = rootframe;
            window.current.activate();
}

now , run the application . you should see the application running with the new start page in the emulator now :)

app

Published at DZone with permission of Senthil Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How to Leverage Method Chaining To Add Smart Message Routing in Java
  • Adding Authentication to a Web Application with Auth0, React, and JWT
  • Applying Kappa Architecture to Make Data Available Where It Matters
  • 11 Best Practices to Do Functional Testing on the Cloud

Comments

Mobile Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo