Right click on your project name and select the Add New Item from the menu and rename your class.

I create a class called MyFriends that is listed in Listing 1. I also inherit this class from INotifyPropertyChanged. This we need to capture notifications when a property value is changed for this class. As you can see from the below code, the MyFriends class has fields name, age, country, profession, mobileno and favQuote. These fields are exposed as public properties.

Now, let's create and get data and bind it to the UI. The code listed in Listing 5 has a method called GetFriendsView. This method gets data from the XAML using the FindResources method and returns a collection. The Final UI looks like Figure 1.

Now, let's look at some validations. The validation code looks like Listing 9 where we can display an error message and its content. The output looks like Figure 5.

void txtAge_ValidationError(object sender, ValidationErrorEventArgs e){// Show the string created in NumberRangeRule.Validate//txtAge.ToolTip = (string)e.Error.ErrorContent;// Show the string pulled out of the exception by the// ExceptionValidationRuleMessageBox.Show((string)e.Error.ErrorContent, "Validation Error");}

In this article, I demonstrated how we can use data binding in WPF and use various conversion and data validations in WPF. Please download the attached solution/project to learn more details and anything I have missed in this article.