title: WPF: Changing MediaElement source with ResourceDictionary
body: <p>I want to use background music in my WPF Application.
  Like you can see here: <a href="https://stackoverflow.com/questions/3148965/how-to-do-background-music-for-my-wpf-application">How to do background music for my WPF-Application?</a></p>
  
  <p>So I use a MediaElement. </p>
  
  <p>Now I want to change the source of it while running the Application.</p>
  
  <p>I'm already doing something similar with some background pictures. There I have different ResourceDictionaries that I'm switching to show different "themes".</p>
  
  <p>One of my dictionaries looks like this:</p>
  
  <pre><code>&lt;ResourceDictionary
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
  
      &lt;ImageBrush x:Key="Backgroundpic" ImageSource="picture.png"/&gt;
  
           ...
  
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>So I can use it in the xaml like this:</p>
  
  <pre><code>...
  &lt;Grid x:Name="Bg" Background="{DynamicResource Backgroundpic}"/&gt;
  ...
  </code></pre>
  
  <p>But HOW can I do that with my MediaElement-Source that I can use it like this:</p>
  
  <pre><code> &lt;MediaElement x:Name="myMediaElement" Source="{DynamicResource ???}" /&gt;
  </code></pre>
  
  <p>I just don't know what to write into my ResourceDictionary.</p>