protected new virtual void Move(int oldIndex, int newIndex) { MVVMControl control = Items[oldIndex]; Items.RemoveAt(oldIndex); Items.Insert(newIndex, control); OnMove(oldIndex, newIndex); }
protected virtual void Insert(int index, object value) { MVVMControl control = (MVVMControl)Convert(value); control._Parent = this; control.DataContext = new MVVMBinding(value); control.Build(Root); Items.Insert(index, control); OnInsert(index, control); }
public MVVMItemsControl(Control control) : base(control) { OnDefaultDataTemplate = () => new MVVMLabel(new Label() { AutoSize = true }) { Text = new MVVMBinding() }; OnItemsControlInsert = (index, currentControl) => { MVVMControl mvvmControl = (MVVMControl)currentControl; Control.Controls.Add(mvvmControl.Control); Control.Controls.SetChildIndex(mvvmControl.Control, index); }; OnItemsControlRemoveAt = index => Control.Controls.RemoveAt(index); OnItemsControlMove = (oldIndex, newIndex) => Control.Controls.SetChildIndex(Control.Controls[oldIndex], newIndex); OnItemsControlReset = () => Control.Controls.Clear(); }
public MVVMBinding( MVVMBindingMode mode, MVVMUpdateSourceTrigger updateSourceTrigger, string path = null, object value = null, MVVMRelativeSource relativeSource = null, string elementName = null, MVVMControl element = null, bool validatesOnExceptions = false ) { if (element != null) { Type = MVVMBindingType.Element; } else if (elementName != null) { Type = MVVMBindingType.ElementName; } else if (relativeSource != null) { Type = MVVMBindingType.RelativeSource; } else if (value != null) { Type = MVVMBindingType.Value; } else { Type = MVVMBindingType.Path; } _Mode = mode; _UpdateSourceTrigger = updateSourceTrigger; Path = path; TargetValue = value; ElementName = elementName; Element = element; ValidatesOnExceptions = validatesOnExceptions; }
internal void Bind(bool isForce = false) { if (!IsFirstBind && !isForce) { switch (Type) { case MVVMBindingType.Value: case MVVMBindingType.Element: case MVVMBindingType.ElementName: case MVVMBindingType.RelativeSource: return; } } IsFirstBind = false; Unbind(); switch (Type) { case MVVMBindingType.Value: break; case MVVMBindingType.Path: { object dataContext = null; if (IsDataContext) { if (Control.Parent != null) { dataContext = Control.Parent.DataContext.GetTargetValue(); } } else { dataContext = Control.DataContext.GetTargetValue(); } BindSource(dataContext); break; } case MVVMBindingType.Element: BindSource(Element); break; case MVVMBindingType.ElementName: { MVVMControl control; Control.Root.ControlNames.TryGetValue(ElementName, out control); BindSource(control); break; } case MVVMBindingType.RelativeSource: { MVVMControl control = Control; switch (RelativeSource.Mode) { case MVVMRelativeSourceMode.Self: break; case MVVMRelativeSourceMode.FindAncestor: int ancestorCount = 0; while (control != null) { if (RelativeSource.AncestorType == null || RelativeSource.AncestorType.IsInstanceOfType(control)) { ancestorCount++; if (ancestorCount == RelativeSource.AncestorLevel) { break; } } control = control.Parent; } break; default: throw new NotImplementedException(RelativeSource.Mode.ToString()); } BindSource(control); break; } default: throw new NotImplementedException(Type.ToString()); } OneWaySetTargetValue(); }
public MVVMBinding(MVVMControl element, string path, MVVMBindingMode mode, MVVMUpdateSourceTrigger updateSourceTrigger) : this(element, path, mode) { _UpdateSourceTrigger = updateSourceTrigger; }
public MVVMBinding(MVVMControl element, string path, MVVMBindingMode mode) : this(element, path) { _Mode = mode; }
public MVVMBinding(MVVMControl element, string path) : this(element) { Path = path; }
public MVVMBinding(MVVMControl element, MVVMUpdateSourceTrigger updateSourceTrigger) : this(element) { _UpdateSourceTrigger = updateSourceTrigger; }
public MVVMBinding(MVVMControl element, MVVMBindingMode mode) : this(element) { _Mode = mode; }
public MVVMBinding(MVVMControl element) { Element = element; Type = MVVMBindingType.Element; }