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);
}
Use SelectedItem instead of SelectedValue, or also set SelectedValuePath:
If you added ListBoxItems to the ListBox you would have to get their
Content: