title: Disable Text Selection in TextBox Style
body: <p>I want to disable the selection of text in a textbox using a style preferably. The reason is that I have a style that makes a textbox look like a textblock until a certain criteria (IsRenaming) is met. These are the nodes of a treeview so I don't want the user to be able to select the text. Here is the style:</p>
  
  <pre><code>&lt;Style x:Key="TextBlockStyleForTextBox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}"&gt;
      &lt;Setter Property="Background" Value="Transparent" /&gt;
      &lt;Setter Property="BorderThickness" Value="0" /&gt;
      &lt;Setter Property="IsReadOnly" Value="True" /&gt;
  &lt;/Style&gt;
  
  &lt;Style x:Key="RenamingTextBox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource TextBlockStyleForTextBox}"&gt;
          &lt;Setter Property="Cursor" Value="Arrow"/&gt;
          &lt;Setter Property="Padding" Value="0" /&gt;
          &lt;Setter Property="Margin" Value="0" /&gt;
          &lt;Style.Triggers&gt;
              &lt;DataTrigger Binding="{Binding IsRenaming}" Value="true"&gt;
                  &lt;DataTrigger.Setters&gt;
                      &lt;Setter Property="TextBox.IsReadOnly" Value="False" /&gt;
                      &lt;Setter Property="Cursor" Value="IBeam" /&gt;
                      &lt;Setter Property="Background" &gt;
                          &lt;Setter.Value&gt;
                              &lt;SolidColorBrush Color="{DynamicResource WhiteColor}"/&gt;
                          &lt;/Setter.Value&gt;
                      &lt;/Setter&gt;
                      &lt;Setter Property="BorderThickness" Value="1" /&gt;
                      &lt;Setter Property="Padding" Value="2" /&gt;
                      &lt;Setter Property="FocusManager.FocusedElement" Value="{Binding RelativeSource={RelativeSource Self}}"/&gt;
                      &lt;Setter Property="behaviors:TextBoxBehavior.SelectAll" Value="True"/&gt;
                  &lt;/DataTrigger.Setters&gt;
              &lt;/DataTrigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>I don't think I am overriding the IsReadOnly anywhere. Here is my textbox definition:</p>
  
  <pre><code>&lt;DataTemplate x:Key="MyTemplate" &gt;
          &lt;TextBox Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" 
                   Tag="{Binding DataContext, RelativeSource={RelativeSource AncestorType=TreeView}}"
                   Style="{StaticResource RenamingTextBox}"&gt;
  </code></pre>
  
  <p>... etc</p>