wpfxaml

WPF: Small border visible around TextBlock?


Hi I have this TextBlock and around that I have a beige round border. but the problem is that i see a small border inside the round border, i was hoping the rounded rectangle to be looking solid and from a single color but it is not.

TextBlock itself does not seem to have BorderThickness to set and for ScrollViewer i can set BorderThickness to 0 but no effect. i do not know where this tiny border comes from.

 <StackPanel>
   <Border CornerRadius="10" BorderThickness="10" BorderBrush="Beige" Background="Beige">
     <ScrollViewer 
       HorizontalScrollBarVisibility="Disabled" 
       VerticalScrollBarVisibility="Auto">
       <TextBlock
         Padding="20"              
         TextWrapping="Wrap"                           
         Text="this is a text"
         FontFamily="Segoe Print"
         FontSize="24" />
     </ScrollViewer>
   </Border>
 </StackPanel>

Solution

  • Remove the border from Border

     <StackPanel>
       <Border CornerRadius="10"
               BorderThickness="0"
               Background="Beige">
    

    P.S. In such a layout, ScrollViewer is useless. It will never be activated, since the behavior for StackPanel is to provide the minimum necessary space to child elements in the orientation direction. And to activate ScrollViewer, you need to limit its size in one way or another.