title: Show/Hide Left and Right Border in WPF RichTextBox codebehind?
body: <p>I want to hide/show WPF <code>RichTextBox</code> left border sometimes in code behind and also for right border sometimes.</p>
  
  <p>Can this be achieved?</p>
  
  <p>I've already tried in XAML like this <code>borderthickness ="3,3,0,3"</code>.  It hides my right side, now I need to show that right side border and also hide my right side border.</p>
  
  <p>How do I do that?</p>
  
  <p><strong>Updated:</strong> </p>
  
  <pre><code>&lt;Window x:Class="View.SingleLineTextMode"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="SingleLineTextMode" Height="300" Width="300" WindowState="Maximized" WindowStyle="None" WindowStartupLocation="CenterScreen" Background="Black"&gt;
  
      &lt;Window.Resources&gt;
          &lt;Style x:Key="MyStyle" BasedOn="{x:Null}" TargetType="{x:Type RichTextBox}"&gt;
              &lt;Setter Property="BorderThickness" Value="3"/&gt;
              &lt;Setter Property="Padding" Value="0,5,0,0"/&gt;
  
              &lt;Setter Property="Template"&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate TargetType="{x:Type RichTextBox}"&gt;
                          &lt;Border x:Name="bg" BorderBrush="Yellow" BorderThickness="3,3,0,3" Background="{TemplateBinding Background}"&gt;
                              &lt;ScrollViewer x:Name="PART_ContentHost"  IsDeferredScrollingEnabled="True" CanContentScroll="False" /&gt;
                          &lt;/Border&gt;
                          &lt;ControlTemplate.Triggers&gt;
  
                              &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                                  &lt;Setter Property="BorderBrush" TargetName="bg" Value="Yellow"/&gt;
                                  &lt;Setter Property="BorderThickness" TargetName="bg" Value="3,3,0,3"/&gt;
                              &lt;/Trigger&gt;
                              &lt;Trigger Property="IsFocused" Value="True"&gt;
                                  &lt;Setter Property="BorderBrush" TargetName="bg" Value="Yellow"/&gt;
                                  &lt;Setter Property="BorderThickness" TargetName="bg" Value="3,3,0,3"/&gt;
                              &lt;/Trigger&gt;
  
                          &lt;/ControlTemplate.Triggers&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
      &lt;/Window.Resources&gt;
      &lt;Grid&gt;
          &lt;!--&lt;RichTextBox Name="txtAppendValue" Height="60" Width="1920" Style="{StaticResource MyStyle}" Margin="0,0,-10,0" FontSize="60" FontFamily="Arial"  IsReadOnly="True" Focusable="False" Cursor="Arrow" BorderThickness="3,3,3,3" IsUndoEnabled="False" UndoLimit="0" TextOptions.TextFormattingMode="Display" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.CacheLength="2,3" VirtualizingPanel.CacheLengthUnit="Page" TextBlock.LineHeight="100" Padding="0"&gt;
          &lt;/RichTextBox&gt;--&gt;
          &lt;RichTextBox Name="txtAppendValue" HorizontalAlignment="Center" VerticalAlignment="Center" Height="60" Width="1920" Style="{StaticResource MyStyle}" Margin="0,0,0,0"  FontSize="40" FontFamily="Arial"  IsReadOnly="True" Focusable="False" Cursor="Arrow"  IsUndoEnabled="False" UndoLimit="0" TextOptions.TextFormattingMode="Display" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.CacheLength="2,3" VirtualizingPanel.CacheLengthUnit="Page" TextBlock.LineHeight="100" &gt;
          &lt;/RichTextBox&gt;
          &lt;Label Name="lblStatusUpdate" &gt;&lt;/Label&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>The above one is my XAML.</p>
  
  <pre><code>txtAppendValue.BorderThickness=new Thickness("0,3,0,3");
  </code></pre>
  
  <p>But its not working.</p>
  
  <p>Regards
  Arjun</p>