//VP private void Button_Click(object sender, RoutedEventArgs e) { var editor = new CollectionControlDialog(_item.PropertyType, _item.DescriptorDefinition.NewItemTypes); editor.ItemsSource = _item.Value as IList; editor.ShowDialog(); }
private void Button_Click(object sender, RoutedEventArgs e) { var editor = new CollectionControlDialog(Type) { ItemsSource = new ObservableCollection <object>(Value.OfType <object>()) }; SetBinding(ValueProperty, new Binding("ItemsSource") { Source = editor, Mode = BindingMode.TwoWay }); /*_item.SetBinding(PropertyItem.ValueProperty, new Binding("Value") * { * Source = this, * Mode = BindingMode.TwoWay * });*/ editor.ShowDialog(); // convert items to array of defined type if (Value != null && _item.PropertyType != Type && _item.PropertyType != null) { var converter = GetType() .GetMethods(BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.Instance) .First(x => x.Name == "ConvertList"); converter = converter.MakeGenericMethod(Type, _item.PropertyType); var result = converter.Invoke(this, new object[] { Value }); _item.Value = result; } }
private void Button_Click( object sender, RoutedEventArgs e ) { CollectionControlDialog editor = new CollectionControlDialog( _item.PropertyType, _item.DescriptorDefinition.NewItemTypes ); Binding binding = new Binding( "Value" ); binding.Source = _item; binding.Mode = _item.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay; BindingOperations.SetBinding( editor, CollectionControlDialog.ItemsSourceProperty, binding ); editor.ShowDialog(); }
private void Button_Click(object sender, RoutedEventArgs e) { CollectionControlDialog editor = new CollectionControlDialog(_item.PropertyType, _item.DescriptorDefinition.NewItemTypes); Binding binding = new Binding("Value"); binding.Source = _item; binding.Mode = _item.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay; BindingOperations.SetBinding(editor, CollectionControlDialog.ItemsSourceProperty, binding); editor.ShowDialog(); }
/// <summary> /// Occurs when the button used to select files has been clicked. /// </summary> /// <param name="sender">N/A</param> /// <param name="e">N/A</param> private void _onButtonClick(object sender, RoutedEventArgs e) { CollectionControlDialog dialog = new CollectionControlDialog(_property.PropertyType, NewItemTypes); Binding binding = new Binding("Value"); binding.Source = _property; binding.Mode = _property.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay; BindingOperations.SetBinding(dialog, CollectionControlDialog.ItemsSourceProperty, binding); dialog.ShowDialog(); }
protected virtual void Button_Click(object sender, RoutedEventArgs e) { var editor = new CollectionControlDialog(_item.PropertyType); _item.SetBinding(PropertyItem.ValueProperty, new Binding("ItemsSource") { Source = editor, Mode = BindingMode.TwoWay }); editor.ShowDialog(); }
//public static readonly DependencyProperty ModelProperty = DependencyProperty.Register("Model", typeof(ConfigurationViewModel), typeof(CollectionControlButton), new FrameworkPropertyMetadata()); //public ConfigurationViewModel Model //{ // get { return Editor.GetValue(ModelProperty) as ConfigurationViewModel; } // set { Editor.SetValue(ModelProperty, value); } //} protected override void SetControlProperties(PropertyItem propertyItem) { RemoveRoutedEventHandlers(Editor, ButtonBase.ClickEvent); SetEditorContent(propertyItem); propertyItem.PropertyChanged += (s, e) => SetEditorContent(propertyItem); Editor.Foreground = Brushes.Gray; Editor.Padding = new Thickness(3); Editor.Click += new RoutedEventHandler(async(s, e) => { var dlg = new CollectionControlDialog { Title = "Config Editor", Width = 1000, Height = 800, MinWidth = 800, MinHeight = 500, ItemsSource = Editor.ItemsSource, NewItemTypes = Editor.NewItemTypes, ItemsSourceType = Editor.ItemsSourceType, IsReadOnly = Editor.IsReadOnly }; var cc = dlg.CollectionControl; //var pg = cc.PropertyGrid; //pg.Loaded += PropertyGrid_Loaded; using (var viewModel = await ConfigurationViewModel.CreateAsync(false)) { //foo.SelectedObject = cc.SelectedItem; //dlg.Loaded += Dlg_Loaded; dlg.DataContext = viewModel; if (dlg.ShowDialog() == true) { // trigger a full revalidation and update the grid var conf = Editor.FindVisualParents().OfType <ArkBot.Controls.Configuration>().FirstOrDefault(); if (conf != null) { AsyncContext.Run(async() => { await conf.UpdateValidation(trigger: true); }); } } } }); }
private void Button_Click(object sender, RoutedEventArgs e) { var editor = new CollectionControlDialog(_item.PropertyType); if (NewItemsTypes != null) { editor.NewItemTypes = NewItemsTypes; } var binding = new Binding("Value"); binding.Source = _item; binding.Mode = _item.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay; BindingOperations.SetBinding(editor, CollectionControlDialog.ItemsSourceProperty, binding); var binding2 = new Binding("NewItemsTypes"); binding2.Source = this; binding2.Mode = BindingMode.OneWay; BindingOperations.SetBinding(editor, CollectionControlDialog.NewItemTypesProperty, binding2); editor.ShowDialog(); }