Using data binding, how do you bind a new object that uses value types?
Simple example:
public class Person() {
private string _firstName;
private DateTime _birthdate;
private int _favoriteNumber;
//Properties
}
If I create a new Person() and bind it to a form with text boxes. Birth Date displays as 01/01/0001 and Favorite Number as 0. These fields are required, but I would like these boxes to be empty and have the user fill them in.
The solution also needs to be able to default fields. In our example, I may want the Favorite Number to default to 42.
I'm specifically asking about Silverlight, but I assume WPF and WinForms probably have the same issue.
EDIT:
I thought of Nullable types, however we are currently using the same domain objects on client and server and I don't want to have required fields be Nullable. I'm hoping the databinding engine exposes a way to know it is binding a new object?