public override void CreateControl(DotvvmControl container, PropertyDisplayMetadata property, DynamicDataContext context)
        {
            var comboBox = new ComboBox()
            {
                EmptyItemText = GetEmptyItemText(property, context)
            };

            container.Children.Add(comboBox);

            comboBox.SetBinding(SelectorBase.ItemTextBindingProperty, context.CreateValueBinding(GetDisplayMember(property, context)));
            comboBox.SetBinding(SelectorBase.ItemValueBindingProperty, context.CreateValueBinding(GetValueMember(property, context)));

            comboBox.SetBinding(SelectorBase.ItemTextBindingProperty, context.CreateValueBinding(GetDisplayMember(property, context)));
            comboBox.SetBinding(SelectorBase.ItemValueBindingProperty, context.CreateValueBinding(GetValueMember(property, context)));
            comboBox.SetBinding(Selector.SelectedValueProperty, context.CreateValueBinding(property.PropertyInfo.Name));
            comboBox.SetBinding(ItemsControl.DataSourceProperty, GetDataSourceBinding(property, context, comboBox));

            var cssClass = ControlHelpers.ConcatCssClasses(ControlCssClass, property.Styles?.FormControlCssClass);

            if (!string.IsNullOrEmpty(cssClass))
            {
                comboBox.Attributes["class"] = cssClass;
            }

            if (container.IsPropertySet(DynamicEntity.EnabledProperty))
            {
                ControlHelpers.CopyProperty(container, DynamicEntity.EnabledProperty, comboBox, SelectorBase.EnabledProperty);
            }
        }
Exemplo n.º 2
0
 private void ApplyPlaceholderProperty(DotvvmControl control)
 {
     if (control.IsPropertySet(Amp.PlaceholderProperty) && control.GetValue <bool>(Amp.PlaceholderProperty) && control is HtmlGenericControl genericControl)
     {
         genericControl.Attributes.Add("placeholder", null);
     }
 }
Exemplo n.º 3
0
 private void ApplyFallbackProperty(DotvvmControl control)
 {
     if (control.IsPropertySet(Amp.FallbackProperty) && control.GetValue <bool>(Amp.FallbackProperty) && control is HtmlGenericControl genericControl)
     {
         genericControl.Attributes.Add("fallback", null);
     }
 }
Exemplo n.º 4
0
        protected override void TransferControlProperties(DotvvmControl source, DotvvmControl target)
        {
            if (source.IsPropertySet(Amp.LayoutProperty))
            {
                target.SetValueRaw(AmpControl.LayoutProperty, source.GetValue <AmpLayout>(Amp.LayoutProperty));
            }

            if (source.IsPropertySet(Amp.WidthProperty))
            {
                target.SetValueRaw(AmpControl.WidthProperty, source.GetValue <string>(Amp.WidthProperty));
            }

            if (source.IsPropertySet(Amp.HeightProperty))
            {
                target.SetValueRaw(AmpControl.HeightProperty, source.GetValue <string>(Amp.HeightProperty));
            }

            base.TransferControlProperties(source, target);
        }
Exemplo n.º 5
0
 public override bool CanTransform(DotvvmControl control)
 {
     return(control is HtmlGenericControl genericControl && genericControl.TagName == "div" && control.IsPropertySet(Amp.LayoutProperty));
 }
Exemplo n.º 6
0
 protected virtual bool ShouldBeRendered(DotvvmControl control, IDotvvmRequestContext context)
 {
     return(!control.IsPropertySet(Amp.ExcludeProperty) || !control.GetValue <bool>(Amp.ExcludeProperty));
 }