title: Setting DataContext to xaml.cs file
body: <p>I've got a <code>Grid</code> and a component inside it.
  The <code>Grid</code> has a custom <code>DataContext</code> while the children has to use the default <code>.xaml.cs</code> file.</p>
  
  <p>Of course, changing the <code>DataContext</code> for the parent control changes it also for the children.</p>
  
  <p>So I need to set the children's <code>DataContext</code> to the <code>xaml.cs</code> file.</p>
  
  <p>I'm trying using <code>DataContext="{Binding}"</code> but it's not working.</p>
  
  <p>How can I do that?</p>
  
  <p>EDIT:
  Here's my code based on the replies</p>
  
  <pre><code>&lt;UserControl x:Class="MyNamespace.MyClass"
  x:Name="MyName"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:lsp="clr-namespace:LSPlugins"
  xmlns:utils="clr-namespace:LSPlugins.Utilities"
  mc:Ignorable="d"
  FontFamily="{StaticResource PhoneFontFamilyNormal}"
  FontSize="{StaticResource PhoneFontSizeNormal}"
  Foreground="{StaticResource PhoneForegroundBrush}"
  d:DesignHeight="480" d:DesignWidth="480"&gt; 
  
      &lt;UserControl.Resources&gt;
          &lt;utils:ColorToSolidColorBrushValueConverter x:Key="ColorConverter"/&gt;
          &lt;lsp:MyModel x:Key="MyModel" x:Name="MyModel"/&gt;
      &lt;/UserControl.Resources&gt;
  
      &lt;Grid x:Name="LayoutRoot" DataContext="{StaticResource MyModel}" Background="{Binding Path=BackgroundColor, Converter={StaticResource ColorConverter}}" Opacity="{Binding Path=BackgroundOpacity}"&gt;        
          &lt;ContentPresenter Content="{Binding PresenterContent}" DataContext="{Binding ElementName=MyName}"/&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>I've tried with both <code>Name</code> and <code>x:Name</code> but it's still not working and it throws this exception:</p>
  
  <blockquote>
    <p>System.Windows.Data Error: BindingExpression path error: 'PresenterContent' property not found on 'MyNamespace.MyModel' 'MyNamespace.MyModel' (HashCode=63183526). BindingExpression: Path='PresenterContent' DataItem='MyNamespace.MyModel' (HashCode=63183526); target element is 'System.Windows.Controls.ContentPresenter' (Name=''); target property is 'Content' (type 'System.Object')..</p>
  </blockquote>