title: WPF: Routing usercontrol command to Mainwindow
body: <p>I must confess I have problems understanding the way wpf works. I have a usercontrol <strong>BottomControl</strong> nested in my <strong>Mainwindow</strong>. If a Button in BottomControl is clicked I want certain changes in my Mainwindow (changing content of a textbox for example) to occur.</p>
  
  <p>The easy thing to do is obviously to just call a public procedure in the Click_Event but this is not quite elegant. I got so far as to use RoutedCommands.</p>
  
  <pre><code>public static readonly RoutedCommand BottomGridReSize = new RoutedCommand();
  </code></pre>
  
  <p>In XAML of Usercontrol </p>
  
  <pre><code>&lt;Button Style="{StaticResource TransparentButton}" Command="{x:Static local:Commands.BottomGridReSize}" &gt;
  </code></pre>
  
  <p>In Code of MainWindow</p>
  
  <pre><code>        void BottomGridReSize_CanExecute(object sender, CanExecuteRoutedEventArgs e)
          {
              e.CanExecute = true;
          }
  
      void BottomGridReSize_Executed(object sender, ExecutedRoutedEventArgs e)
         {
            \\Do some stuff
         }
  </code></pre>
  
  <p>Obviously Mainwindow can't use these events because ist doesn't recognize them. What am I missing?</p>
  
  <p>Any help would very much be appreciated</p>
  
  <p>Jon</p>