Exemplo n.º 1
0
        /// <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(FrameworkElement target, Parameter parameter, FrameworkElement 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);
            }
        }
Exemplo n.º 2
0
        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 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 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);
 }
        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);
        }
Exemplo n.º 6
0
        /// <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(FrameworkElement target, Parameter parameter, FrameworkElement control,
            string propertyName, BindingMode bindingMode)
        {
            if (string.IsNullOrEmpty(propertyName))
            {
                propertyName = ConventionManager.GetElementConvention(control.GetType()).ParameterProperty;
            }

            if (!string.IsNullOrEmpty(propertyName))
            {
                var binding = new Binding()
                {
                    SourceObject = control,
                    SourcePath = propertyName,
                    TargetObject = parameter,
                    TargetPath = "Value",
                    Mode = bindingMode
                };

                parameter.BindingManager.Bindings.Add(binding);
            }
        }