title: Windows 10 Universal Compiled binding (x:Bind) conflict with ViewModel
body: <p>I want to bind an element in a page to dependency property in code behind with compiled binding and same time bind another element to ViewModel with usual binding. But it gives a runtime error.</p>
  
  <p>Here is my xaml code.</p>
  
  <pre><code>&lt;Page
  x:Class="XbindingProblem.MainPage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="using:XbindingProblem"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  DataContext="{Binding Main, Source={StaticResource Locator}}"
  mc:Ignorable="d"&gt;
  &lt;Page.Resources&gt;
      &lt;DataTemplate x:Key="UserDataTemplate" x:DataType="local:User"&gt;
          &lt;StackPanel&gt;
              &lt;TextBlock Text="{x:Bind Name}" /&gt;
              &lt;TextBlock Text="{x:Bind Age}" /&gt;
          &lt;/StackPanel&gt;
      &lt;/DataTemplate&gt;
  &lt;/Page.Resources&gt;
  &lt;Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt;
      &lt;StackPanel&gt;
          &lt;TextBlock Text="{Binding Title}"/&gt;
          &lt;ContentPresenter ContentTemplate="{StaticResource UserDataTemplate}" Content="{x:Bind CurrentUser, Mode=OneWay}"/&gt;
      &lt;/StackPanel&gt;        
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here CurrentUser is dependency property which is initially null and then change in run time. This gives following runtime error.</p>
  
  <pre><code>Incorrect type passed into template. Based on the x:DataType global::XbindingProblem.User was expected.
  </code></pre>
  
  <p>The problem is it passes the ViewModel into UserDataTemplate instead of CurrentUser dependency property when CurrentUser is null.</p>
  
  <p>Can anyone have a good explanation on this problem?</p>