views:

49

answers:

0

I have a data form that I assign a new Entity class as its current item. The problem is when i tab from one textbox on the dataform to the next the first one reverts back to a blank textbox. If hit save it will save the values you typed buy you cant see them once you tab or click on the next texbox. Below is my xaml and code behind.

<

DataForm:DataForm x:Name="NewCustomerForm" AutoGenerateFields="False" CommandButtonsVisibility="None" AutoCommit="False" AutoEdit="False">
            <DataForm:DataForm.EditTemplate>
                <DataTemplate>
                <StackPanel>
                    <DataForm:DataField Label="First Name">
                        <TextBox Text="{Binding Customer.FirstName, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}"/>
                    </DataForm:DataField>
                    <DataForm:DataField Label="Middle Name">
                        <TextBox Text="{Binding Customer.MiddleName, Mode=TwoWay}"/>
                    </DataForm:DataField>
                    <DataForm:DataField Label="Last Name">
                        <TextBox Text="{Binding Customer.LastName, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}"/>
                    </DataForm:DataField>
                    <DataForm:DataField Label="Address 1">
                        <TextBox Text="{Binding Contact.Address1, Mode=TwoWay}"/>
                    </DataForm:DataField>
                    <DataForm:DataField Label="Address 2">
                        <TextBox Text="{Binding Contact.Address2, Mode=TwoWay}"/>
                    </DataForm:DataField>
                    <DataForm:DataField Label="City">
                        <TextBox Text="{Binding Contact.City, Mode=TwoWay}"/>
                    </DataForm:DataField>
                    <DataForm:DataField Label="State">
                        <TextBox Text="{Binding Contact.State, Mode=TwoWay}"/>
                    </DataForm:DataField>
                    <DataForm:DataField Label="Zip">
                        <TextBox Text="{Binding Contact.Zip, Mode=TwoWay}"/>
                    </DataForm:DataField>
                    <DataForm:DataField Label="Phone Home">
                        <TextBox Text="{Binding Contact.PhoneHome, Mode=TwoWay}"/>
                    </DataForm:DataField>
                    <DataForm:DataField Label="Phone Cell">
                        <TextBox Text="{Binding Contact.PhoneCell, Mode=TwoWay}"/>
                    </DataForm:DataField>
                    <DataForm:DataField Label="Email">
                        <TextBox Text="{Binding Contact.Email, Mode=TwoWay}"/>
                    </DataForm:DataField>
                    </StackPanel>
                </DataTemplate>
            </DataForm:DataForm.EditTemplate>
        </DataForm:DataForm>

 public partial class NewCustomer : ChildWindow
    {
        public CustomerContactLink newCustomer { get; set; }

        public NewCustomer()
        {
            InitializeComponent();
            newCustomer = new CustomerContactLink();
            newCustomer.Customer = new Customer();
            newCustomer.Contact = new Contact();
            NewCustomerForm.CurrentItem = newCustomer;
            NewCustomerForm.BeginEdit();
            this.Closing += new EventHandler<System.ComponentModel.CancelEventArgs>(NewCustomer_Closing);
        }

        void NewCustomer_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {

        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            bool commited = NewCustomerForm.CommitEdit();
            if (commited && (!NewCustomerForm.IsItemChanged && NewCustomerForm.IsItemValid))
            {
                this.DialogResult = true;
            }
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            NewCustomerForm.CancelEdit();
            this.DialogResult = false;
        }
    }