Wpf Text Box , Is set to mandatory and need to change border color .

Hi,
In wpf application . We a text box as mandatory and set the border color as red . We need to change the color to black when user enter values .
How to do that in xaml page .
Thank YOu

Hi Jeevan,
you could use a Style with a trigger for that.
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style TargetType="TextBox" x:Key="TextBoxMandatoryStyle">
<Style.Triggers>
<Trigger Property="Text" Value="">
<Setter Property="BorderBrush" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Style="{StaticResource TextBoxMandatoryStyle}"/>
<TextBox Grid.Row="1" Style="{StaticResource TextBoxMandatoryStyle}"/>
<TextBox Grid.Row="2" />
</Grid>
</Window>
Thomas Claudius Huber
"If you can't make your app run faster, make it at least look & feel extremly fast"
My latest Pluralsight-courses:
XAML Layout in Depth
Windows Store Apps - Data Binding in Depth
twitter: @thomasclaudiush
homepage: www.thomasclaudiushuber.com

Similar Messages

Maybe you are looking for

  • Error when activating DSO data

    On activation, I see the following error in ST22: Invalid column name 'TCTIVAL60' Any idea? Thanks in advance!

  • Teradata deski #Multivalue Error

    When refreshing the XIR2+Sp2 deski report with freehand sql data provider with Teradata V2r6 getting #Multivalue error and when editing dataprovider report displays data with out any errors. Please Assists

  • How to get full screen as a default?

    My display screen is half size. Each time I log on I have to go to view and then to presentation view to view full screen. Is there a way for it to default to full screen?

  • Record audio from microphone in .swf

    Hello i need to record audio with help of microphone, can any 1 tell me how it is possible and what is the possible way to do this. I am having flash 8 and flash communication(media) server 2.0 Please let me know which are the possible ways to this t

  • Aperture crashes with display

    Hi there, having successfully overcome installation problems (the update to 1.0.1 would not install) I now have connected a second display. Result: Aperture crashes each time I want to start it. "Try again" yields the same result, o I clicked the but