public void Attach(PropertyViewItem property, PropertyItem info) { if (info.CanWrite) { var binding = new Binding("Value") { Mode = BindingMode.TwoWay, Source = info, ValidatesOnExceptions = true, ValidatesOnDataErrors = true }; BindingOperations.SetBinding(maskededit, SfMaskedEdit.ValueProperty, binding); } else { maskededit.IsEnabled = false; var binding = new Binding("Value") { Source = info, ValidatesOnExceptions = true, ValidatesOnDataErrors = true }; BindingOperations.SetBinding(maskededit, SfMaskedEdit.ValueProperty, binding); } }
public void Attach(PropertyViewItem property, PropertyItem info) { Value = (TargetParam)info.Value; Values = new List <uint>(); foreach (var v in Enum.GetValues(Value.Target.GetType())) { Values.Add((uint)v); } foreach (var name in Enum.GetNames(Value.Target.GetType())) { string t = MainWindow.Provider.GetLocalizedString("O_" + name); Control.CBox.Items.Add(t ?? name); } var binding1 = new Binding("Value.Target") { Mode = BindingMode.TwoWay, Source = info, ValidatesOnExceptions = true, ValidatesOnDataErrors = true, Converter = new EnumUIntConverter(), ConverterParameter = Value.Target.GetType() }; BindingOperations.SetBinding(Control.CBox, ComboBox.TagProperty, binding1); var binding2 = new Binding("Value.Occupations") { Mode = BindingMode.TwoWay, Source = info, ValidatesOnExceptions = true, ValidatesOnDataErrors = true, Converter = new StringFormatToIntConverter(), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; BindingOperations.SetBinding(Control.Btn, Button.TagProperty, binding2); Control.CBox.SelectedIndex = Values.IndexOf((uint)Value.Target); Control.Btn.IsEnabled = (EnumTarget)Control.CBox.Tag == EnumTarget.occupation_list; Control.Btn.Content = Value.Occupations.ToString(); }
public void Detach(PropertyViewItem property) { }
private static PropertyViewItem FindPropertyItemRecursively(PropertyViewItem root, NodeViewModel target) { return(root.DataContext == target ? root : root.Properties.Select(x => FindPropertyItemRecursively(x, target)).FirstOrDefault(x => x != null)); }
private static NodeViewModel GetNode(PropertyViewItem item) { return(item.DataContext as NodeViewModel); }
private void ExpandSingleProperties(PropertyViewItem item) { var node = GetNode(item); // The data context of the item might be a "disconnected object" if (node == null) { return; } var rule = GetRule(node); if (node.Parent != null) { switch (rule) { case ExpandRule.Always: // Always expand nodes that have this rule (without tracking them) item.SetCurrentValue(ExpandableItemsControl.IsExpandedProperty, true); break; case ExpandRule.Never: // Always collapse nodes that have this rule (without tracking them) item.SetCurrentValue(ExpandableItemsControl.IsExpandedProperty, false); break; case ExpandRule.Once: { // Expand nodes that have this rule only if they have never been collapsed previously var propertyPath = GetNode(item).DisplayPath; if (!collapsedPropertyPaths.Contains(propertyPath)) { item.SetCurrentValue(ExpandableItemsControl.IsExpandedProperty, true); break; } } goto default; default: { // If the node was saved as expanded, persist this behavior var propertyPath = GetNode(item).DisplayPath; if (expandedPropertyPaths.Contains(propertyPath)) { item.SetCurrentValue(ExpandableItemsControl.IsExpandedProperty, true); } else if (node.Parent.Children.Count == 1) { // If the node is an only child, let's expand it item.SetCurrentValue(ExpandableItemsControl.IsExpandedProperty, true); // And keep a track of it, in case it has some siblings incoming expandedItems.Add(item); } else { // If one of its siblings has been expanded because it was an only child at the time it was created, let's unexpand it. // This will prevent to always have the first item expanded since the property items are generated as soon as a child is added. expandedItems.Where(x => GetNode(x).Parent == node.Parent).ForEach(x => x.SetCurrentValue(ExpandableItemsControl.IsExpandedProperty, false)); } } break; } } foreach (var container in item.Properties) { ExpandSingleProperties(container); } }
public void Detach(PropertyViewItem property) { image.Source = null; image = null; }
public void Detach(PropertyViewItem property) { passwordBox = null; }
public void Detach(PropertyViewItem property) { throw new NotImplementedException(); }
public void Attach(PropertyViewItem property, PropertyItem info) { }
public override void Attach(PropertyViewItem property, PropertyItem info) { var binding = base.CreatePropertyInfoBinding(info, enumCombo); BindingOperations.SetBinding(enumCombo, ComboBox.SelectedItemProperty, binding); }
public override void Detach(PropertyViewItem property) { comboBox = null; }