Textbox border curve
-
Hi,I want curve in all corners of textbox in wpf.. I got this by following code in dynamic resource. But from that i can't input anything in textbox. Any Suggessions? <Style x:Key="UserNameTextBox" TargetType="{x:Type TextBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBoxBase}"> <Border Name="Border" Background="#FFEBE9E9" BorderBrush="#FF8B8787" BorderThickness="1" CornerRadius="3" Padding="3"/> </ControlTemplate> </Setter.Value> </Setter> </Style>
-
Hi,I want curve in all corners of textbox in wpf.. I got this by following code in dynamic resource. But from that i can't input anything in textbox. Any Suggessions? <Style x:Key="UserNameTextBox" TargetType="{x:Type TextBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBoxBase}"> <Border Name="Border" Background="#FFEBE9E9" BorderBrush="#FF8B8787" BorderThickness="1" CornerRadius="3" Padding="3"/> </ControlTemplate> </Setter.Value> </Setter> </Style>
This should work,
<Style x:Key="UserNameTextBox" TargetType="{x:Type TextBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBoxBase}">
<Border Name="Border" Background="#FFEBE9E9" BorderBrush="#FF8B8787" BorderThickness="1" CornerRadius="3" Padding="3">
<ScrollViewer x:Name="PART_ContentHost"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> -
This should work,
<Style x:Key="UserNameTextBox" TargetType="{x:Type TextBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBoxBase}">
<Border Name="Border" Background="#FFEBE9E9" BorderBrush="#FF8B8787" BorderThickness="1" CornerRadius="3" Padding="3">
<ScrollViewer x:Name="PART_ContentHost"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> -
Thanks a lot.. Can you please explain shortly about, <ScrollViewer x:Name="PART_ContentHost"/>
The ControlTemplate for a TextBox must contain exactly one element that is tagged as the content host element; this element will be used to render the contents of the TextBox. To tag an element as the content host, assign it the special name PART_ContentHost. The content host element must be either a ScrollViewer or an AdornerDecorator. The content host element may not host any child elements. From here, MSDN[^]