this is the xaml code
<TextBox Grid.Column="1" Height="23" HorizontalAlignment="Left" Name="textBox1" VerticalAlignment="Top" Width="203" Margin="0,5,0,0"
Text="{Binding UsrNm, Mode=TwoWay, ValidatesOnExceptions=True}" />
<TextBox Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Name="textBox2" VerticalAlignment="Top" Width="203" Margin="0,5,0,0"
Text="{Binding UsrPwd, Mode=TwoWay, ValidatesOnExceptions=True}" />
<Button Content="LogIn" Grid.Column="1" Grid.Row="2" Height="39" HorizontalAlignment="Left" Margin="112,27,0,0" Name="button1" VerticalAlignment="Top" Width="91" Click="button1_Click" />
and this is the .cs file in mailpagexaml.cs
public MainPage()
{
InitializeComponent();
LoginInfo lgin = new LoginInfo();
LayoutRoot.DataContext = lgin;
}
private void button1_Click(object sender, RoutedEventArgs e)
{
foreach (var ele in LayoutRoot.Children)
{
if (ele is TextBox)
{
(ele as TextBox).GetBindingExpression(TextBox.TextProperty).UpdateSource();
}
}
}
public class LoginInfo
{
private string _usrnm;
private string _usrpwd;
public string UsrNm
{
get { return _usrnm; }
set { _usrnm = value; }
}
public string UsrPwd
{
get { return _usrpwd; }
set { _usrpwd = value; }
}
}
but it is not working for validation...
i am following this tutorial
Silverlight 4 : Data Validation - Tip of the Day - Part 1[
^]
please help me...