title: How to make a keyboard scrollable readonly WPF TextBox?
body: <p>It seems such a simple thing to do: use a TextBox to display some output and allow the user to cut and paste from it, scroll it but not edit it.</p>
  
  <p>BUT: if a TextBox is readonly, then it loses most of its keyboard behaviour. You can click on it and select text using the invisible cursor, but it will not scroll or navigate.</p>
  
  <p>I have this (terrible) solution.</p>
  
  <pre><code>&lt;TextBox Focusable="True"
       VerticalScrollBarVisibility="Auto"
       HorizontalScrollBarVisibility="Auto"
       FontFamily="Consolas" FontSize="10pt"
       Foreground="{Binding Path=OutputTextColour}" 
       Text="{Binding Path=OutputText}"
       Background="White" PreviewKeyDown="TextBox_PreviewKeyDown" /&gt;
  </code></pre>
  
  <p>And a handler to throw away any attempts to edit:</p>
  
  <pre><code>   private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e) {
    // the IsReadOnly flag on the control doesn't let the navigation keys work! WPF BUG?
    if (!(e.Key == Key.Down || e.Key == Key.Up || e.Key == Key.Left || e.Key == Key.Right 
       || e.Key == Key.Home || e.Key == Key.End || e.Key == Key.PageDown || e.Key == Key.PageUp 
       || e.Key == Key.Tab || e.Key == Key.Escape))
      e.Handled = true;
  }
  </code></pre>
  
  <p>I have also tried a readonly TextBox inside a ScrollViewer, but it seems the TextBox, even when readonly, still swallows the navigation keystrokes and the ScrollView never sees them. If the ScrollViewer gets the focus then scrolling works and cut/copy/paste do not!</p>
  
  <p>Yes, I could probably get all that to work by some fancy footwork with PreviewKeyDown, but really I just want a TextBox that plays nice!</p>