private void AddBindings() { _customer = new Customer(); _bindingManager = new BindingManager(); _bindingManager.BindOnValidation = true; _bindingManager.Bindings.Add(new Binding(CustomerNameUI, "Text", _customer, "Name")); _bindingManager.Bindings.Add(new Binding(CustomerNameBO, "Text", _customer, "Name")); var address = _customer.Address; _bindingManager.Bindings.Add(new Binding(CustomerAddressCountryUI, "Text", address, "Country")); _bindingManager.Bindings.Add(new Binding(CustomerAddressCountryBO, "Text", address, "Country")); _bindingManager.Bindings.Add(new Binding(CustomerAddressZipCodeUI, "Text", _customer, "Address.ZipCode")); _bindingManager.Bindings.Add(new Binding(CustomerAddressZipCodeBO, "Text", _customer, "Address.ZipCode")); var invoice = _customer.Invoice; _bindingManager.Bindings.Add(new Binding(CustomerInvoiceInvoiceNumberUI, "Text", invoice, "InvoiceNumber")); _bindingManager.Bindings.Add(new Binding(CustomerInvoiceInvoiceNumberBO, "Text", invoice, "InvoiceNumber")); var invoicedateBinding = new Binding(CustomerInvoiceInvoiceDateUI, "Text", _customer, "Invoice.InvoiceDate"); invoicedateBinding.Converter = new DateTimeToDateConverter(); invoicedateBinding.ConverterCulture = CultureInfo.CurrentCulture; _bindingManager.Bindings.Add(invoicedateBinding); _bindingManager.Bindings.Add(new Binding { TargetObject = CustomerInvoiceInvoiceDateBO, TargetPath = "Text", SourceObject = _customer, SourcePath = "Invoice.InvoiceDate", Converter = new DateTimeToDateConverter(), ConverterCulture = CultureInfo.CurrentCulture }); }
private void AddBindings() { _customer = new Customer(); _bindingManager = new BindingManager(); _bindingManager.BindOnValidation = true; _bindingManager.Bindings.Add( new TypedBinding<TextBox, Customer>(CustomerNameUI, t => t.Text, _customer, s => s.Name)); _bindingManager.Bindings.Add( new TypedBinding<Label, Customer>(CustomerNameBO, t => t.Text, _customer, s => s.Name)); var address = _customer.Address; _bindingManager.Bindings.Add( new TypedBinding<TextBox, Address>(CustomerAddressCountryUI, t => t.Text, address, s => s.Country)); _bindingManager.Bindings.Add( new TypedBinding<Label, Address>(CustomerAddressCountryBO, t => t.Text, address, s => s.Country)); _bindingManager.Bindings.Add( new TypedBinding<TextBox, Customer>(CustomerAddressZipCodeUI, t => t.Text, _customer, s => s.Address.ZipCode)); _bindingManager.Bindings.Add( new TypedBinding<Label, Customer>(CustomerAddressZipCodeBO, t => t.Text, _customer, s => s.Address.ZipCode)); var invoice = _customer.Invoice; _bindingManager.Bindings.Add( new TypedBinding<TextBox, Invoice>(CustomerInvoiceInvoiceNumberUI, t => t.Text, invoice, s => s.InvoiceNumber)); _bindingManager.Bindings.Add( new TypedBinding<Label, Invoice>(CustomerInvoiceInvoiceNumberBO, t => t.Text, invoice, s => s.InvoiceNumber)); var invoicedateBinding = new TypedBinding<TextBox, Customer>(CustomerInvoiceInvoiceDateUI, t => t.Text, _customer, s => s.Invoice.InvoiceDate); invoicedateBinding.Converter = new DateTimeToDateConverter(); invoicedateBinding.ConverterCulture = CultureInfo.CurrentCulture; _bindingManager.Bindings.Add(invoicedateBinding); _bindingManager.Bindings.Add(new TypedBinding<Label, Customer> { TargetObject = CustomerInvoiceInvoiceDateBO, TargetExpression = t => t.Text, SourceObject = _customer, SourceExpression = s => s.Invoice.InvoiceDate, Converter = new DateTimeToDateConverter(), ConverterCulture = CultureInfo.CurrentCulture }); }