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 894933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:28:36+00:00 2026-05-15T14:28:36+00:00

I have an WPF-Application with 3 different UserControls in the MainWindow and only one

  • 0

I have an WPF-Application with 3 different UserControls in the MainWindow and only one of these is visible at the time. It’s like having 3 different pages and you able to switch from one page to another when you like it. First page is like a start-screen. Second is like the “general view”. And the third page shows details. Switching between them works fine with Storyboard. I just make the visible page invisible (opacity to zero) and move it out of the visible window- area and move the new page into the visible window-area and make it visible. So far so good… (Hope you understood what I wanted to tell^^)

Now I want to have background-music that plays, just when the detail-page is displayed. And only then. Not when the user looks at the startscreen ir the general view.

I think I have to make something with a mediaelement. And start or stop the mediaelement with my storyboards.

But how do I handle the mediaelements in my Storyboards?

  • 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-15T14:28:37+00:00Added an answer on May 15, 2026 at 2:28 pm

    You have the right idea:

    • Use a MediaElement in whatever layout container (grid, border, whatever) your details page is put in

      <MediaElement x:Name="myMediaElement" />

    • Make your storyboard resource that has a MediaTimeline in it

      <Window.Resources>
      <Storyboard x:Key="PlaySoundStoryboard">
          <MediaTimeline Storyboard.TargetName="myMediaElement" Source="whatever.mp3" />
      </Storyboard>
      

    • I know with buttons and things you can use event triggers to start and stop the story board:

          <Grid x:Name="LayoutRoot">
          <Grid.Triggers>
              <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="playbutton">
                  <BeginStoryboard Storyboard="{StaticResource PlaySoundStoryboard}" Name="theStoryboard" />
              </EventTrigger>
              <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="stopbutton">
                  <StopStoryboard BeginStoryboardName="theStoryboard" />
              </EventTrigger>
          </Grid.Triggers>
          <MediaElement x:Name="myMediaElement" />
          <Button Name="playbutton">play</Button>
          <Button Name="stopbutton">stop</Button>
      </Grid>
      

    But I don’t know how you would do this for the visibility of the container. IsVisibleChanged would require you to look at the argument which you can’t do in XAML (to my knowledge). You may need to the trigger the animation using a code behind.

    Hope this helps…

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

Sidebar

Related Questions

I have two different ways of displaying items in a WPF application. The first
I have a WPF application with several windows. I would like to define GLOBAL
I have a WPF Browser Application consisting mostly of wpf pages which I'm developing
I have a WPF application that allows users to create questions of all different
hi we have a PRISM WPF MVP application, we would like to have a
I have a WPF application in VS 2008 with some web service references. For
I have a WPF application that runs fine under XP as an administrator. When
I have a WPF application using Aero Glass. When using the application under a
Please help! Background info I have a WPF application which accesses a SQL Server
I have a simple WPF application which I am trying to start. I am

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.