Round Corner TextBox in WPF

Kailash Chandra Behera | Tuesday, January 10, 2017


This atricle provides code snippet for creating Round Corner Textbox using XAML in WPF

Code Snippet

 <Window x:Class="RoundCornerTextBox.MainWindow"  
     Title="Round Corner Textbox Example" Height="350" Width="525">  
     <ControlTemplate x:Key="RoundTextboxCornterTemplate" TargetType="{x:Type TextBoxBase}">  
       <Border Background="{TemplateBinding Background}"   
         x:Name="Bd" BorderBrush="Black"  
         BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5">  
         <ScrollViewer x:Name="PART_ContentHost"/>  
         <Trigger Property="IsEnabled" Value="False">  
           <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" TargetName="Bd"/>  
           <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>  
         <Trigger Property="Width" Value="Auto">  
           <Setter Property="MinWidth" Value="100"/>  
         <Trigger Property="Height" Value="Auto">  
           <Setter Property="MinHeight" Value="20"/>  
     <TextBox Template="{StaticResource RoundTextboxCornterTemplate}" Text="Kailash" Height="30" FontSize="18" Width="200" Margin="5"></TextBox>  

Related Articles

  1. Data Validation in WPF
  2. WPF Round Corner Button with click effects
  3. Round Corner PasswordBox in WPF
  4. Round Corner TextBox in WPF
  5. WPF Custom Datagrid Control(Filterable)
  6. WPF Round Corner ListBox
  7. Custom RadioButtonListBox With Image
  8. RadiobuttonList in WPF
  9. Custom CheckedListBox in WPF


This code snippet described how to create round corner Textbox using XAML code in WPF, hope this article may helpful to you.