title: How to Call Method in XAML from the MainWindow?
body: <p>I'm trying to call a method in MainWindow.xaml from MainWindow.xaml.cs.
  I can't find anywhere how will that work.</p>
  
  <p>Let's say for example i have KeyBinding in my xaml code and i want when CTRL+E is pressed the <code>MethodIWantToCall</code> to be called.</p>
  
  <pre><code>&lt;Page x:Class="Example"
        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" 
        xmlns:local="clr-namespace:Example"
        mc:Ignorable="d"&gt;
  &lt;Page.InputBindings&gt;
          &lt;KeyBinding Command="{Binding MethodIWantToCall}" Gesture="Ctrl+E"/&gt;
  &lt;/Page.InputBindings&gt;
  &lt;/Page&gt;
  </code></pre>
  
  <pre><code>public partial class Example : Page
  {
      public Example()
      {
          InitializeComponent();
      }
  
      public void MethodIWantToCall()
      {
          //Body
      }
  }
  </code></pre>
  
  <p>Of course when i run the code and press Ctrl+E nothing will happen.
  If i put the Method in other class it will work, but in my situation i need that to be this Page which the xaml is behind.</p>