private void BindOnce() { if (_isBindingSet) { return; } search.DataBindings.Add(new FormsBinding("Enabled", ViewModel.Criteria, "IsValid")); fastDate.DataSource = FastDateOptionList.GetFastDateOptionList(FastDateOptionsFacade.Instance); fastDate.ValueMember = "FastDateOptionName"; fastDate.DisplayMember = "FastDateOptionDescription"; fastDate.SelectedIndex = 0; dateType.DataSource = ViewModel.Criteria.DateTypeList; dateType.ValueMember = "DateTypeName"; dateType.DisplayMember = "DateTypeDescription"; dateType.SelectedIndex = 0; //BindingManager.BindOnValidation = true; // as it is, it will select the first item of the list // comment to start with no item selected var gridBinding = new Binding(); gridBinding.SourceObject = ViewModel; gridBinding.SourcePath = "ListItemId"; gridBinding.TargetObject = this; gridBinding.TargetPath = "RowId"; gridBinding.Mode = BindingMode.TwoWay; BindingManager.Bindings.Add(gridBinding); // uncomment to start with no item selected /*listBox1.ClearSelected(); * * var binding = new Binding(); * binding.SourceObject = ViewModel; * binding.SourcePath = "ListItemId"; * binding.TargetObject = listBox1; * binding.TargetPath = "RowId"; * binding.Mode = BindingMode.TwoWay; * BindingManager.Bindings.Add(binding);*/ var bindingDisplayName = new Binding(); bindingDisplayName.SourceObject = ViewModel; bindingDisplayName.SourcePath = "DisplayName"; bindingDisplayName.TargetObject = listNavigator; bindingDisplayName.TargetPath = "Text"; bindingDisplayName.Mode = BindingMode.OneWayToTarget; BindingManager.Bindings.Add(bindingDisplayName); BindText(criteria_FullText); BindText(criteria_StartDate); BindText(criteria_EndDate); _isBindingSet = true; }
private void AddBindings() { _customer = new Customer(); _bindingManager = new BindingManager(); _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 Bind() { if (_isBindingSet) { return; } BindingManager.BindOnValidation = true; var binding = new Binding(); binding.SourceObject = ViewModel; binding.SourcePath = "DisplayName"; binding.TargetObject = panelTitle; binding.TargetPath = "Text"; binding.Mode = BindingMode.OneWayToTarget; BindingManager.Bindings.Add(binding); var bindingRegisterId = new Binding(); bindingRegisterId.SourceObject = ViewModel; bindingRegisterId.SourcePath = "DisplayName"; bindingRegisterId.TargetObject = registerId; bindingRegisterId.TargetPath = "Text"; bindingRegisterId.Mode = BindingMode.OneWayToTarget; BindingManager.Bindings.Add(bindingRegisterId); BindText(model_RegisterDate); BindText(model_DocumentType); BindText(model_DocumentReference); BindText(model_DocumentEntity); BindText(model_DocumentDept); BindText(model_DocumentClass); BindText(model_DocumentDate); BindText(model_Subject); BindText(model_SendDate); BindText(model_RecipientName); BindText(model_RecipientTown); BindText(model_ArchiveLocation); BindText(model_Notes); errorWarnInfoProvider.DataSource = ViewModel.Model; BindFormReadOnly(); BindTextBoxReadOnly(model_RegisterDate); BindTextBoxReadOnly(model_DocumentType); BindTextBoxReadOnly(model_DocumentReference); BindTextBoxReadOnly(model_DocumentEntity); BindTextBoxReadOnly(model_DocumentDept); BindTextBoxReadOnly(model_DocumentClass); BindTextBoxReadOnly(model_DocumentDate); BindTextBoxReadOnly(model_Subject); BindTextBoxReadOnly(model_SendDate); BindTextBoxReadOnly(model_RecipientName); BindTextBoxReadOnly(model_RecipientTown); BindTextBoxReadOnly(model_ArchiveLocation); BindTextBoxReadOnly(model_Notes); _isBindingSet = true; }
/// <summary> /// Creates a binding on a <see cref="Parameter" />. /// </summary> /// <param name="target">The target to which the message is applied.</param> /// <param name="parameter">The parameter object.</param> /// <param name="control">The actual control to bind to.</param> /// <param name="propertyName">The name of the property to bind to.</param> /// <param name="bindingMode">The binding mode to use.</param> public static void BindParameter(Control target, Parameter parameter, Control control, string propertyName, BindingMode bindingMode) { if (string.IsNullOrEmpty(propertyName)) { var convention = ConventionManager.GetElementConvention(control.GetType()); if (convention != null) { propertyName = convention.ParameterProperty; } } if (!string.IsNullOrEmpty(propertyName)) { var binding = new Binding() { SourceObject = control, SourcePath = propertyName, TargetObject = parameter, TargetPath = "Value", Mode = bindingMode }; parameter.BindingManager.Bindings.Add(binding); } }
private void SetVisibilityBindings() { var binding = new Binding(); binding.SourceObject = _viewModel; binding.SourcePath = "StudentOpen"; binding.TargetObject = studentEditPanel; binding.TargetPath = "Visible"; binding.Mode = BindingMode.OneWayToTarget; _bindingManager.Bindings.Add(binding); }