title: Accessing elements of XAML file in .cs file in WPF
body: <p>I am creating a UI and I have two XAML files and two cs files:</p>
  
  <p><code>Main.xaml</code>
  <code>Library.xaml</code></p>
  
  <p><code>Main.xaml.cs</code>
  <code>Library.xaml.cs</code> </p>
  
  <p>I have declared a Button in <code>Library.xaml</code> and given a Name <strong><code>my_button</code></strong> and I want to access that Button in Main.cs. </p>
  
  <p>How can I do that?</p>
  
  <p><code>Library.xaml</code></p>
  
  <pre><code>&lt;Style TargetType="Button"&gt;
    &lt;Setter Property="Template"&gt;
      &lt;ControlTemplate&gt;
        &lt;Button x:Name=my_button Content="Click"&gt;&lt;/Button&gt;
      &lt;/ControlTemplate&gt;
    &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>