Пример #1
0
        /// <summary>
        /// Binds the visible and enabled properties of a <see cref="Control"/> to
        /// the ViewModel properties, using a <see cref="BindingManager"/>.
        /// </summary>
        /// <param name="namedElements">The list of elements in scope.</param>
        /// <param name="viewModel">The view model to bind to.</param>
        /// <param name="bindingManager">The binding manager to use.</param>
        public static void BindComponentProxyProperties(List <Control> namedElements, object viewModel,
                                                        BindingManager bindingManager)
        {
            if (namedElements == null)
            {
                throw new ArgumentNullException(nameof(namedElements));
            }
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }
            if (bindingManager == null)
            {
                throw new ArgumentNullException(nameof(bindingManager));
            }

            foreach (var control in namedElements)
            {
                var binderAgent = BinderManager.GetBinderAgent(control.GetType());
                if (binderAgent != null)
                {
                    binderAgent.BindVisualProperties(control, viewModel, bindingManager);
                }
            }
        }
Пример #2
0
        public override void PostInitialize()
        {
            BinderManager.Bind();

            if (AppConfig.MiniProfilerEnable)
            {
                MiniProfilerEF6.Initialize();
            }
        }
Пример #3
0
 public static void Run()
 {
     BinderManager.Bind();
 }
Пример #4
0
        protected override void UpdateTarget(object target, string propertyName, object value)
        {
            Element targetElement = (Element)target;

            // Convert the value into a string if it isn't already... do this with a template
            // if one is specified, or resort to ToString as a fallback.
            string content = null;

            if (value is string)
            {
                content = (string)value;
            }
            else
            {
                string templateName = (string)targetElement.GetAttribute("data-template");
                if (String.IsNullOrEmpty(templateName) == false)
                {
                    Template template = Application.Current.GetTemplate(templateName);
                    if (template != null)
                    {
                        content = template(value, /* index */ 0, /* context */ null);
                    }
                }
                else
                {
                    content = value.ToString();
                }
            }

            // Raise contentUpdating event, so it allows any behaviors attached to this
            // element to be notified
            MutableEvent updatingEvent = Document.CreateEvent("Custom");

            updatingEvent.InitCustomEvent("contentUpdating", /* canBubble */ false, /* canCancel */ false, null);
            targetElement.DispatchEvent(updatingEvent);

            // Deactivate the content, in case current content has attached behaviors or bindings.
            Application.Current.DeactivateFragment(targetElement, /* contentOnly */ true);

            // Update the element with the new value.
            base.UpdateTarget(targetElement, propertyName, content);

            // If the property that was updated was the innerHTML, then activate any
            // binding expressions or behaviors that might have been specified within the
            // new markup.
            if ((String.IsNullOrEmpty(content) == false) && (propertyName == "innerHTML"))
            {
                BinderManager binderManager = (BinderManager)Behavior.GetBehavior(targetElement, typeof(BinderManager));
                if (binderManager != null)
                {
                    Application.Current.ActivateFragment(targetElement, /* contentOnly */ true, binderManager.Model);
                }
            }

            // Raise contentUpdated event, so it allows any behaviors attached to this
            // element to be notified
            MutableEvent updatedEvent = Document.CreateEvent("Custom");

            updatedEvent.InitCustomEvent("contentUpdated", /* canBubble */ false, /* canCancel */ false, null);
            targetElement.DispatchEvent(updatedEvent);
        }
Пример #5
0
 private static void PanelExBinderAgent()
 {
     BinderManager.AddBinderAgent <PanelEx>(PanelExHandler.BindVisualProperties);
 }