private void HandleXamlBindingDefinition(XamlBindingDefinition xamlBindingDefinition)
        {
            PerspexObject subjectObject = xamlBindingDefinition.Target;
            _propertyBinder.Create(xamlBindingDefinition);

            var observableForDataContext = subjectObject.GetObservable(Control.DataContextProperty);
            observableForDataContext.Where(o => o != null).Subscribe(_ => BindToDataContextWhenItsSet(xamlBindingDefinition));
        }
        private void BindToDataContextWhenItsSet(XamlBindingDefinition definition)
        {
            var target = definition.Target;
            var dataContext = target.DataContext;

            var binding = _propertyBinder.GetBinding(target, definition.TargetProperty);
            binding.BindToDataContext(dataContext);
        }
Example #3
0
        public XamlBinding Create(XamlBindingDefinition xamlBinding)
        {
            if (xamlBinding.Target == null)
            {
                throw new InvalidOperationException();
            }

            if (xamlBinding.TargetProperty == null)
            {
                throw new InvalidOperationException();
            }

            var binding = new XamlBinding(this.typeConverterProvider)
            {
                BindingMode = xamlBinding.BindingMode,
                SourcePropertyPath = xamlBinding.SourcePropertyPath,
                Target = xamlBinding.Target,
                TargetProperty = xamlBinding.TargetProperty
            };

            this.bindings.Add(binding);
            return binding;
        }
Example #4
0
        public XamlBinding Create(XamlBindingDefinition xamlBinding)
        {
            if (xamlBinding.Target == null)
            {
                throw new InvalidOperationException();
            }

            if (xamlBinding.TargetProperty == null)
            {
                throw new InvalidOperationException();
            }

            var binding = new XamlBinding(_typeConverterProvider)
            {
                BindingMode        = xamlBinding.BindingMode,
                SourcePropertyPath = xamlBinding.SourcePropertyPath,
                Target             = xamlBinding.Target,
                TargetProperty     = xamlBinding.TargetProperty
            };

            _bindings.Add(binding);
            return(binding);
        }