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

  • Home
  • SEARCH
  • 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 7684771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:06:15+00:00 2026-05-31T19:06:15+00:00

i am working with wpf media element.i want to change the media element source

  • 0

i am working with wpf media element.i want to change the media element source according to listbox item.

i created next button when clicking the next buton ,listbox item changed to next item.i dont know how to change the media element source to next listbox item when clicking the next button..

can any one have idea on this.

plz help me.thanks in advance….

my .xaml file…

<MediaElement Margin="7,29,80,6" Name="mediaElement1" LoadedBehavior="Manual" 
    AllowDrop="True" MediaOpened="mediaElement1_MediaOpened" 

  Grid.IsSharedSizeScope="False" ScrubbingEnabled="True" IsEnabled="True"  
       Stretch="Fill" Drop="mediaElement1_Drop" ClipToBounds="False" 

 Visibility="Visible" OpacityMask="DarkRed" BufferingStarted="btn_play_click" 
  MediaEnded="mediaElement1_MediaEnded"  

  MouseLeftButtonUp="mediaElement1_MouseLeftButtonUp" Grid.Row="1" />


  <ListBox Margin="0,31,0,18" Name="listBox1" HorizontalAlignment="Right" Width="74"  
  Grid.Row="1" MouseDoubleClick="listBox1_MouseDoubleClick" SelectedIndex="0" 
   SelectionMode="Multiple" AllowDrop="True"> </ListBox> 

my next button code in .cs file is

private void btn_next_Click(object sender, RoutedEventArgs e){   
  listBox1.SelectedIndex = listBox1.SelectedIndex + 1;
  mediaElement1.Source = new System.Uri(listBox1.SelectedValue as string);
}
  • 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-31T19:06:17+00:00Added an answer on May 31, 2026 at 7:06 pm

    Use SelectedItem instead of SelectedValue, or also set SelectedValuePath:

    private void btn_next_Click(object sender, RoutedEventArgs e)
    {    
        listBox1.SelectedIndex = listBox1.SelectedIndex + 1; 
        mediaElement1.Source = new System.Uri(listBox1.SelectedItem as string); 
    }
    

    If you added ListBoxItems to the ListBox you would have to get their Content:

    private void btn_next_Click(object sender, RoutedEventArgs e)
    {    
        listBox1.SelectedIndex = listBox1.SelectedIndex + 1;
        ListBoxItem item = listBox1.SelectedItem as ListBoxItem;
        mediaElement1.Source = new System.Uri(item.Content as string); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using media element to render video in WPF. All videos are working
I am working with WPF. I want to create keyboard shortcuts for my WPF
I am working on WPF app and I want to get news feed using
Working in WPF, writing a custom user control. I am trying to change the
I am working on wpf PropertyGrid (PG) control and I want the PG to
Hello Guys I am working WPF app and I want to retrive all the
I am working on WPF application and I want to retrieve News Feed using
I am working with WPF and C#. I want to fire an event when
I am working with WPF application and I want to assign a value of
I am working on WPF application.I have bound my textblock to my button. 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.