How to remove border from Textbox in WPF?

42,071

Solution 1

Try BorderThickness="0"

<TextBox x:Name="SearchBox" BorderThickness="0" HorizontalAlignment="Left" Height="40" Width="296" Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Center"  SelectionBrush="Black" Background="#00000000" Foreground="#FF5B5B5B" FontSize="25" FontFamily="Segoe UI Light" BorderBrush="#00000000" CaretBrush="#FF6C6C6C"/>

Solution 2

you can remove the border by just setting the BorderBrush property to Transparent.

Share:
42,071

Related videos on Youtube

Fᴀʀʜᴀɴ Aɴᴀᴍ
Author by

Fᴀʀʜᴀɴ Aɴᴀᴍ

Updated on October 23, 2020

Comments

  • Fᴀʀʜᴀɴ Aɴᴀᴍ
    Fᴀʀʜᴀɴ Aɴᴀᴍ over 3 years

    enter image description here

    These borders appear when they are clicked or hovered and don't go until the focus is lost. There are borders on all four sides but since it is embedded in a shorter grid, the top and bottom ones are not visible. How to remove these borders? Please provide an example if possible.

    XAML:

    <Border x:Name="SearchBorder" BorderThickness="1" HorizontalAlignment="Left" Height="40" Margin="672,34,0,0" VerticalAlignment="Top" Width="355" Background="#3F000000">
            <Border.BorderBrush>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#4C000000" Offset="0"/>
                    <GradientStop Color="#3FFFFFFF" Offset="1"/>
                </LinearGradientBrush>
            </Border.BorderBrush>
            <Grid>
                <TextBox x:Name="SearchBox" HorizontalAlignment="Left" Height="40" Width="296" Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Center"  SelectionBrush="Black" Background="#00000000" Foreground="#FF5B5B5B" FontSize="25" FontFamily="Segoe UI Light" BorderBrush="#00000000" CaretBrush="#FF6C6C6C"/>
                <TextBlock HorizontalAlignment="Left" Height="23" Margin="320,0,0,0" TextWrapping="Wrap" Text="&#xF002;" VerticalAlignment="Center" Width="21" FontFamily="FontAwesome" FontSize="25" Foreground="#FF919191"/>
                <Rectangle HorizontalAlignment="Left" Margin="311,-2,0,0" Width="1">
                    <Rectangle.Stroke>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#3F404040" Offset="0"/>
                            <GradientStop Color="#3F686868" Offset="1"/>
                            <GradientStop Color="#59DADADA" Offset="0.502"/>
                        </LinearGradientBrush>
                    </Rectangle.Stroke>
                </Rectangle>
            </Grid>
        </Border>
    
    • almulo
      almulo almost 9 years
      That doesn't look like Combo's default style, so it'd help if you shared your XAML Styles and Templates.
    • Fᴀʀʜᴀɴ Aɴᴀᴍ
      Fᴀʀʜᴀɴ Aɴᴀᴍ almost 9 years
      xaml code posted. there are no additional styles
    • almulo
      almulo almost 9 years
      Have you tried BorderThickness="0"?
  • Fᴀʀʜᴀɴ Aɴᴀᴍ
    Fᴀʀʜᴀɴ Aɴᴀᴍ almost 6 years
    Pretty sure that won't work. Check my code it does have BorderBrush set to #00000000 in the XAML