Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

facing problem in validating wpf control

$
0
0

hi

my xaml code is

<Label x:Name="lblDeviceName" Content="Device Type Name" Grid.Column="0" Grid.Row="0"/><TextBox x:Name="txtDevicename"   Grid.Column="1" Grid.Row="0"><TextBox.Text><Binding Path="DeviceName" ValidatesOnDataErrors="True" UpdateSourceTrigger="PropertyChanged"><Binding.ValidationRules><ExceptionValidationRule /></Binding.ValidationRules></Binding></TextBox.Text></TextBox><Label x:Name="lblGTIN"  Content="GTIN" Grid.Column="3" Grid.Row="0"/><TextBox x:Name="txtGTIN" Grid.Column="4" Grid.Row="0"/><Label x:Name="lblBasicCode"  Content="Basic Code" Grid.Column="0" Grid.Row="1"/><TextBox x:Name="txtBasicCode" Grid.Column="1" Grid.Row="1"/>

after that i have one model class where the code is

public string DeviceName { get { return _deviceName; }

set { _deviceName = value; if (String.IsNullOrEmpty(_deviceName)) { MessageBox.Show("field compulsary"); //throw new ApplicationException("Customer name is mandatory."); } } }

and in my xaml. cs file i have bind the model class

the problem is that , i have to first enter in that textbox and when i am deleting the text it throws error msg , i want that as soon as the user clink on the second textbox it should display error that first textbox is empty.

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>