void DatePickerEditor_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { var property = e.NewValue as BindableProperty; if (property != null) { CustomEditorBinder.BindProperty(this, property); var propertyBinding = new Binding("Value"); propertyBinding.Source = property; propertyBinding.Converter = new DateTimeToNullableDateTimeConverter(); this.SetBinding(DatePicker.SelectedDateProperty, propertyBinding); } }
void MultilineTextEditor_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { BindableProperty bindableProperty = DataContext as BindableProperty; if (bindableProperty == null) { return; } CustomEditorBinder.BindProperty(this, bindableProperty); var propertyBinding = new Binding("BindableValue"); propertyBinding.Source = bindableProperty; propertyBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; this.SetBinding(TextBox.TextProperty, propertyBinding); }
public override void OnApplyTemplate() { BindableProperty property = DataContext as BindableProperty; if (property == null) { return; } CustomEditorBinder.BindProperty(this, property); ElementProperty elementProperty = property.Property as ElementProperty; if (elementProperty != null) { viewModel = elementProperty.DeclaringElement.ChildElement(elementProperty.DeclaringProperty.Name) as ElementCollectionViewModel; } if (viewModel != null) { var properties = TypeDescriptor.GetProperties(viewModel.CollectionElementType).OfType <PropertyDescriptor>().Where(x => x.Attributes.OfType <ConfigurationPropertyAttribute>().Any()).ToArray(); foreach (var childProperty in properties.Where(x => x.IsBrowsable)) { Collection.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(75, GridUnitType.Star) }); } Collection.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(25) }); Redraw(); viewModel.ChildElementsCollectionChange += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ChildElements_CollectionChanged); } }
void FlagsEditor_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { BindableProperty bindableProperty = DataContext as BindableProperty; if (bindableProperty == null) { return; } CustomEditorBinder.BindProperty(this, bindableProperty); property = bindableProperty.Property; if (property != null) { if (!property.PropertyType.IsEnum) { throw new InvalidOperationException(Properties.Resources.EnumEditorExceptionInvalidPropertyType); } RefreshVisual(property); property.PropertyChanged += new PropertyChangedEventHandler(property_PropertyChanged); } }
void CustomAttributesEditor_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { property = (BindableProperty)e.NewValue; CustomEditorBinder.BindProperty(this, property); NameValueCollection value = (NameValueCollection)property.Value; list = new ObservableCollection <KeyValueItem>(); foreach (string key in value) { var item = new KeyValueItem { Key = key, Value = value[key] }; item.DeleteCommand = new KeyValueItemDeleteCommand(this, item); ChangeMonitor monitor = new ChangeMonitor(this, item); monitor.PropertyChanged += new PropertyChangedEventHandler(monitor_PropertyChanged); changeMonitors.Add(monitor); list.Add(item); } AddNewItem(); this.Items.ItemsSource = list; }