title: How to handle events from ResourceDictionary without using ResourceDictionary Code-Behind?
body: <p>I would like help regarding how to handle events from controls in a ResourceDictionary (e.g. Styles.xaml) without using ResourceDictionary Code-Behind (e.g. Styles.xaml.cs), mainly because I want the Styles.xaml to just be there for styling.</p>
  
  <p>My scenario is, I have a Custom Page which uses a ResourceDictionary for DataTemplate styles (I am using a TemplateSelector). However, the problem I am currently having is for handling events. For example:</p>
  
  <p>I have this in my <strong>Styles.xaml</strong>:</p>
  
  <pre><code>.
  .
  &lt;Button Click="Button_Click"/&gt;
  .
  </code></pre>
  
  <p>And I declare this in the <strong>CustomPage.xaml.cs</strong> :</p>
  
  <pre><code>private void Button_Click(object sender, RoutedEventArgs e)
  {
    // some code
  }
  </code></pre>
  
  <p>However, it does not work. Is there any way to explicitly tell that I want to use that particular Event Handler for the button's click event? Additionally, is it possible to have different handlers for each page e.g.</p>
  
  <p><strong>CustomPage2.xaml.cs:</strong></p>
  
  <pre><code>private void Button_Click(object sender, RoutedEventArgs e)
  {
     // some different code from CustomPage.xaml.cs
  }
  </code></pre>
  
  <p>Thank you!</p>