title: Set Media Element source in C#
body: <p>I am trying to dynamically set a video .mv4 file as the source for my media element in my windows 8 app.</p>
  
  <pre><code>   var x = new MediaElement { Source = new Uri("ms-appx:/Assets/vid1.mv4") };
  
          this.DefaultViewModel["Video"] = x;
  </code></pre>
  
  <p>I use this code in my XAML cs file, in an attempt to bind it to the Medai element set up in the XAML page</p>
  
  <pre><code>&lt;Paragraph Margin="0 40 0 0" LineStackingStrategy="MaxHeight"&gt;
                                          &lt;InlineUIContainer&gt;
                                              &lt;MediaElement x:Name="media" 
                                               Source="{Binding Video}" 
                                              Width="500" Height="300" AutoPlay="True" /&gt;
                                              &lt;/InlineUIContainer&gt;
                                      &lt;/Paragraph&gt;
  </code></pre>
  
  <p>But this doesn't work. However if I set the source directly in the media element on the XAML page <code>Source="Assets/vid1.m4v"</code>, it plays fine.</p>
  
  <p>How do I set a video in C# for binding into a XAML windows 8 app page?</p>