title: Playlist for WPF MediaElement app
body: <p>I'm learning C# and WPF by building a WMP-type app. The code below runs fine, selecting a movie from the listbox runs it in the media element. The problem I'm having is finding a way to automatically start the next movie after one ends. Thank You.</p>
  
  <p>The xml file that provides a list of movies:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  </code></pre>
  
  <p>
  
      Bear
      c:\movies\Bear.wmv
  
  
      Butterfly
      c:\movies\Butterfly.wmv
  
  
      Lake
      c:\movies\Lake.wmv
  
  </p>
  
  <p>xaml</p>
  
  <pre><code>&lt;Window x:Class="WpfAppPlaylistTest.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Window1" Height="300" Width="425"&gt;
  
  &lt;Window.Resources&gt;
      &lt;XmlDataProvider x:Key="myMoviesXML"
  
                           Source="c:\Movies\media1.xml"
                           XPath="media"
          /&gt;
  &lt;/Window.Resources&gt;
  
  &lt;Grid DataContext="{Binding ElementName=movieList, Path=SelectedItem}"&gt;
      &lt;ListBox ItemsSource="{Binding Source={StaticResource myMoviesXML}, XPath=//media//movie}" IsSynchronizedWithCurrentItem="True" 
       Name="movieList" HorizontalAlignment="Right" Width="114" Margin="0,48,12,32"&gt;
          &lt;ListBox.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;TextBlock Text="{Binding XPath=title}"/&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;
      &lt;/ListBox&gt;
      &lt;MediaElement Source="{Binding XPath=filename}" LoadedBehavior="Play" Name="mediaElement1" Margin="12,26,136,12"  /&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>