Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: CheckComboBox and [Flags] enum

$
0
0
Hi,

This looks like a different problem. You are not using the dynamic enum anymore, but a Dictionary. In v3.0, the propertyGrid will support the Dictionary type property and use the CollectionEditor to edit this property.
If you want to use the CheckComboBox for Dictionaries, here's the CheckComboBoxEditor that could work :
public class CheckComboBoxEditor : TypeEditor<CheckComboBox>, ITypeEditor
    {
      protected override void SetValueDependencyProperty()
      {
         ValueProperty = CheckComboBox.ItemsSourceProperty;
      }

      protected override void SetControlProperties( PropertyItem propertyItem )
      {
        Editor.DisplayMemberPath = "Value.DisplayText";
        Editor.SelectedMemberPath = "Value.IsChecked";
        base.SetControlProperties( propertyItem );
      }

      protected override CheckComboBox CreateEditor()
      {
        return new CheckComboBox();
      }

      protected override void ResolveValueBinding( PropertyItem propertyItem )
      {
        var _binding = new Binding( "Value" );
        _binding.Source = propertyItem;
        _binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
        _binding.Mode = BindingMode.TwoWay;
        _binding.Converter = CreateValueConverter();
        BindingOperations.SetBinding( Editor, ValueProperty, _binding );

        Editor.Initialized += Editor_Initialized;
      }

      private void Editor_Initialized( object sender, EventArgs e )
      {
        Editor.EndInit();
      }
    }
BUT...
There is a problem with nested PropertyItems : they are not working. "Value.IsChecked" won't be found. Issue https://wpftoolkit.codeplex.com/workitem/22216 has been created.

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>