title: Access objects in UserControl from MainWindow in WPF
body: <p>I have this simple XAML, how can I change the <code>Text</code> property of the <code>TextBlock</code> in <code>UserControl1</code> from the <code>MainWindow</code>?</p>
  
  <pre><code>&lt;Window x:Class="RefactorXAML.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:refactorXaml="clr-namespace:RefactorXAML"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="100"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="100"&gt;&lt;/RowDefinition&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;Grid&gt;
              &lt;refactorXaml:UserControl1&gt;&lt;/refactorXaml:UserControl1&gt;
          &lt;/Grid&gt;
          &lt;Grid Grid.Row="1"&gt;
              &lt;Button&gt;Change Text&lt;/Button&gt;
          &lt;/Grid&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  
  &lt;UserControl x:Class="RefactorXAML.UserControl1"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
           mc:Ignorable="d" 
           d:DesignHeight="300" d:DesignWidth="300"&gt;
  
          &lt;TextBlock x:Name="MyTextblock"&gt;StackOverflow&lt;/TextBlock&gt;
  &lt;/UserControl&gt;
  </code></pre>