Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7082727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:05:25+00:00 2026-05-28T07:05:25+00:00

In my windows phone 7 app I’m using the following code to navigate to

  • 0

In my windows phone 7 app I’m using the following code to navigate to a page

 private void button2_Click(object sender, RoutedEventArgs e)
        {
           NavigationService.Navigate(new Uri("/Views/Game.xaml, UriKind.RelativeOrAbsolute));
        }

In the OnNavigatedTo event of Game.xaml.cs I use the following code to play two wav files one after another. In order for me to prevent both audio play at the same time, I use while loop to wait until the first audio is finish before the second file is played. I believe this is what causing the first audio to play before the game page is displayed. Is there a better way of doing this?

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{            
    playAudio("intro.wav");
    while (MySoundEffect.State == SoundState.Playing)
    {
    }

    playAudio("firstQuestion.wav");

    base.OnNavigatedTo(e);                 
}

The following is the code for playAudio.

 protected void playAudio(string fileName)
        {
            Stream stream = TitleContainer.OpenStream("audio/" + fileName);
            SoundEffect effect = SoundEffect.FromStream(stream);
            MySoundEffect = effect.CreateInstance();
            FrameworkDispatcher.Update();
            MySoundEffect.Play();
        }

MySoundEffect is a property of the Game class.

private SoundEffectInstance _MySoundEffect;

        public SoundEffectInstance MySoundEffect
        {
            get { return _MySoundEffect; }
            set { _MySoundEffect = value; }
        }

Whenever user click the button, the sound

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:05:25+00:00Added an answer on May 28, 2026 at 7:05 am

    To answer your question in the title, you could try the same with the
    Loaded
    event handler instead of the OnNavigateTo. This way, your audio files will start playing
    only after the page is loaded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a Windows Phone app. I have the following C# code: private void
In my windows phone 7 app, I have the following code to handle the
I'm developing a Windows Phone app. I have the following XAML code: <Grid x:Name=ContentPanel
Hey, im doing a little app for my smart phone, using Windows Mobile 6.
Lets set the stage Doing a windows phone app, and trying to authenticate using
I have some C# code in a Windows Phone app... WebRequest wrq = WebRequest.CreateHttp(http://bing.com);
I pass a querystring to a page in my Windows Phone app : page.xaml?key=val&key2=val
I'm developing a Windows Phone app. I have the following XAML: <!--ContentPanel --> <Grid
I'm developing a Windows Phone app. I'm using an image and when I select
I'm working on a Windows Phone app and am having the following problem. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.