So I started with WPF and it been a painful experience, coming from WinForms.
I have text boxes that I'm binding to my object's properties. I'm trying to use data annotations to validate required fields and and:
When I click on the button, I want that ErrorMessage "Enter name!!!." to display, and obviously return false.
Can someone tell me how to connect the pieces.
Will the message come as a popup (MessageBox.Show) or will I need to create labels next to each required textbox.
In asp.net webforms you can use requiredfieldvalidator for this.
I have text boxes that I'm binding to my object's properties. I'm trying to use data annotations to validate required fields and and:
my xaml looks something like:public class Person
{
[Required(ErrorMessage = "Enter name!!!.")]
public string Name{ get; set; }
}
.
.
.
<TextBox x:Name="txtName" Text="{Binding Path=Name}" />
<Button Content="Submit" x:Name="btnSubmit" />
When I click on the button, I want that ErrorMessage "Enter name!!!." to display, and obviously return false.
Can someone tell me how to connect the pieces.
Will the message come as a popup (MessageBox.Show) or will I need to create labels next to each required textbox.
In asp.net webforms you can use requiredfieldvalidator for this.