title: Window not detecting key input when changing datacontext
body: <p>Window xaml:</p>
  
  <pre><code>&lt;Window x:Class="wndVerkoopOrderInvoer"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:vm="clr-namespace:Delivery_Manager.DeliveryManager.ViewModel"
  xmlns:vw="clr-namespace:Delivery_Manager.DeliveryManager.View"
  xmlns:st="clr-namespace:Delivery_Manager.Settings;assembly=Delivery_Manager_Settings"
  xmlns:sf="clr-namespace:Microsoft.Surface.Presentation.Controls;assembly=Microsoft.Surface.Presentation"
  Title="Bestel" Height="526" Width="1063"
  WindowStyle="None" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"&gt;
  &lt;Window.Resources&gt;
      &lt;ResourceDictionary Source="..\ResourceDictionaries\resdictMain.xaml" /&gt;
  &lt;/Window.Resources&gt;
  &lt;Grid PreviewKeyDown="cc1_PreviewKeyDown"&gt;
      &lt;ContentControl Grid.ZIndex="2" Name="cc1" Content="{Binding VMFullScreen}"&gt;
          &lt;ContentControl.Resources&gt;
              &lt;DataTemplate DataType="{x:Type vm:VMVerkoopTakeaway}"&gt;
                  &lt;vw:ucVerkoopTakeaway/&gt;
              &lt;/DataTemplate&gt;
              &lt;DataTemplate DataType="{x:Type vm:VMFullScreenVerkoop}"&gt;
                  &lt;vw:ucVerkoopOrderInvoer/&gt;
              &lt;/DataTemplate&gt;
              &lt;DataTemplate DataType="{x:Type vm:VMFullScreenPayment}"&gt;
                  &lt;vw:ucVerkoopKlantBetaalMethode/&gt;
              &lt;/DataTemplate&gt;
          &lt;/ContentControl.Resources&gt;
      &lt;/ContentControl&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>code behind:</p>
  
  <pre><code>    Private Sub cc1_PreviewKeyDown(sender As System.Object, e As System.Windows.Input.KeyEventArgs)
      Try
  
          If e.Key = Key.F12 Then
  
              If TypeOf (Me.cc1.DataContext) Is VMVerkoop Then
                  Dim vm As VMVerkoop = Me.cc1.DataContext
  
                  If TypeOf (vm.VMFullScreen) Is VMVerkoopTakeaway Then
                      Dim vmv As VMVerkoopTakeaway = vm.VMFullScreen
                      If vmv Is Nothing Then Exit Sub
  
                      If vmv.VMVerkoop.CanBetalen() Then
                          vmv.VMVerkoop.BetalenCommand.Execute(Nothing)
                      End If
                  ElseIf TypeOf (vm.VMFullScreen) Is VMFullScreenPayment Then
                      Dim vmv As VMFullScreenPayment = vm.VMFullScreen
                      If vmv Is Nothing Then Exit Sub
  
                      If vmv.CanBetalen() Then
                          vmv.BetalingCommand.Execute(Nothing)
                      End If
                  End If
  
              End If
          End If
  
      Catch ex As Exception
          WriteErrorLog("wndVerkoopOrderInvoer", "cc1_PreviewKeyDown", ex)
      End Try
  End Sub
  </code></pre>
  
  <p>This window is initiated with the usercontrol called ucVerkoopTakeaway and his viewmodel and every time i press a key on my keyboard the subroutine will run correctly, but when the datacontext of the window changes (i.e: i load one of the others usercontrol into the window) i cant make the subroutine to run.. Do i need to do something on the window.DataContextChanged?? Any help will be appreciated.</p>
  
  <p>Thanks you</p>