Example #1
0
        public static CommandBindingExpression RegisterExtensionCommand(this DotvvmControl control, Delegate action, string methodUsageId)
        {
            var id           = control.GetDotvvmUniqueId() + methodUsageId;
            var propertyName = control.GetType().FullName + "/" + methodUsageId;
            var property     = DotvvmProperty.Register <object, ExtensionCommands>(propertyName);
            var binding      = new CommandBindingExpression(action, id);

            control.SetBinding(property, binding);
            return(binding);
        }
Example #2
0
        public static CommandBindingExpression RegisterExtensionCommand(this DotvvmControl control, Delegate action, string methodUsageId)
        {
            var bindingService = control.GetValue(Internal.RequestContextProperty).CastTo <IDotvvmRequestContext>()
                                 .Configuration.ServiceProvider.GetRequiredService <BindingCompilationService>();
            var id           = control.GetDotvvmUniqueId() + methodUsageId;
            var propertyName = control.GetType().FullName + "/" + methodUsageId;
            var property     = DotvvmProperty.ResolveProperty(typeof(PropertyBox), propertyName) ?? DotvvmProperty.Register(propertyName, typeof(object), typeof(PropertyBox), null, false, null, typeof(PropertyBox), throwOnDuplicitRegistration: false);
            var binding      = new CommandBindingExpression(bindingService, action, id);

            control.SetBinding(property, binding);
            return(binding);
        }
Example #3
0
        public static CommandBindingExpression RegisterExtensionCommand(this DotvvmControl control, Delegate action, string methodUsageId)
        {
            var bindingService = control.GetValue(Internal.RequestContextProperty).CastTo <IDotvvmRequestContext>()
                                 .Configuration.ServiceLocator.GetService <BindingCompilationService>();
            var id           = control.GetDotvvmUniqueId() + methodUsageId;
            var propertyName = control.GetType().FullName + "/" + methodUsageId;
            var property     = DotvvmProperty.Register <object, PropertyBox>(propertyName);
            var binding      = new CommandBindingExpression(bindingService, action, id);

            control.SetBinding(property, binding);
            return(binding);
        }
Example #4
0
        public static void TransferProperty(this DotvvmControl sourceControl, DotvvmControl targetControl, DotvvmProperty targetProperty,
                                            DotvvmProperty sourceProperty)
        {
            IBinding binding = sourceControl.GetBinding(sourceProperty);

            if (binding != null)
            {
                targetControl.SetBinding(targetProperty, binding);
            }
            else
            {
                var value = sourceProperty.GetValue(sourceControl);
                if (value != null)
                {
                    targetControl.SetValue(targetProperty, value);
                }
            }
        }
Example #5
0
 public static DotvvmControl WithBinding(this DotvvmControl control, DotvvmProperty property, BindingExpression expression)
 {
     control.SetBinding(property, expression);
     return(control);
 }