title: Binding vs. x:Bind, using StaticResource as a default and their differences in DataContext
body: <p>I've spent the better of half a day trying to make the <code>ItemTemplate</code> of a <code>ListView</code> with a <code>UserControl</code> configurable through means of a <code>DependencyProperty</code> on said <code>UserControl</code>. I've come across some weird inconsistencies regarding the two different <code>Binding</code> methods available on Windows 10 UAP platform ( <code>Binding</code> and <code>x:Bind</code>).</p>
  
  <p>The <code>UserControl</code> looks like this and is part of a custom calendar component.</p>
  
  <pre><code>&lt;UserControl
     x:Class="FlowDesigner.UserControls.CalendarDayView"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:local="using:FlowDesigner.UserControls"
     xmlns:vw="using:FlowDesigner.ViewModels"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:uc="using:FlowDesigner.UserControls"
     mc:Ignorable="d"
     d:DesignHeight="300"
     d:DesignWidth="400"
     x:Name="DateControl"&gt;
     &lt;UserControl.Resources&gt;
        &lt;DataTemplate x:Key="DefaultDataTemplate" x:DataType="vw:Event" &gt;
            &lt;uc:EventListTemplate IsToday="{Binding Date, Converter={StaticResource IsTodayConverter}}" 
                                Date="{Binding Date, Mode=OneWay}"
                                Summary="{Binding Path=Summary, Mode=OneWay}" /&gt;
        &lt;/DataTemplate&gt;
     &lt;/UserControl.Resources&gt;
     &lt;RelativePanel Background="White" BorderBrush="Black" BorderThickness="1" DataContext="{Binding ElementName=DateControl}"&gt;
         &lt;TextBlock x:Name="DayText" TextAlignment="Center" VerticalAlignment="Center" /&gt;
         &lt;TextBlock x:Name="MonthText" TextAlignment="Center" VerticalAlignment="Center" RelativePanel.RightOf="DayText" /&gt;
         &lt;ListView x:Name="EventList" ItemsSource="{x:Bind Events, Mode=OneWay}" 
                ItemTemplate="{Binding Path=EventItemTemplate, Mode=OneWay, FallbackValue={StaticResource DefaultDataTemplate}, TargetNullValue={StaticResource DefaultDataTemplate}}" 
                RelativePanel.Below="DayText" RelativePanel.AlignLeftWithPanel="True" RelativePanel.AlignRightWithPanel="True"&gt;
  
          &lt;/ListView&gt;
      &lt;/RelativePanel&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>The <code>EventItemTemplate</code> is a <code>DependencyProperty</code> of the <code>UserControl</code>.</p>
  
  <pre><code>public DataTemplate EventItemTemplate
  {
      get { return (DataTemplate)GetValue(EventItemTemplateProperty); }
      set { SetValue(EventItemTemplateProperty, value); }
  }
  
  public static readonly DependencyProperty EventItemTemplateProperty =
          DependencyProperty.Register("EventItemTemplate", typeof(DataTemplate), typeof(CalendarDayView), new PropertyMetadata(null));
  </code></pre>
  
  <p>Which is altered on one of the root pages to style the <code>ListView</code> in one way or the other, like so.</p>
  
  <pre><code>&lt;Style TargetType="uc:CalendarDayView"&gt;
      &lt;Setter Property="EventItemTemplate"&gt;
          &lt;Setter.Value&gt;
              &lt;DataTemplate x:DataType="vw:Event" &gt;
                  &lt;TextBlock Text="{Binding Summary, Mode=OneWay}" /&gt;
              &lt;/DataTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>This is actually a working version, but I had to tinker around with it quite a bit. The first attempts were made by me with both <code>x:Bind</code> and <code>Binding</code> and without the <code>DataContext</code> on the <code>RelativePanel</code> as the <code>UserControl</code> is now. <code>x:Bind</code> would be functional when setting a value to <code>EventItemTemplate</code> in the root page, but it would not be able to use the default <code>DataTemplate</code> specified by the <code>StaticResource</code> when the root page did not specify anything. <code>Binding</code> on the other hand would use the default <code>DataTemplate</code> at all times, even when the the root page had a set an other value to <code>EventItemTemplate</code>. </p>
  
  <p>By setting the <code>DataContext</code> on the <code>RelativePanel</code> to the <code>UserControl</code> <code>Binding</code> started worked like wanted it too. <code>x:Bind</code> still shows the same behavior. </p>
  
  <p>Now I understand that <code>Binding</code> does not by default bind to the <code>UserControl</code>'s <code>DataContext</code>, but I'm still not entirely sure why <code>x:Bind</code> doesn't work. Is this intended behavior or is there something wrong with my entire scheme here and is what I came up with just a lucky hack?</p>