I have a standard tree view control. It contains a tree of items. When I select a tree view item, I display the properties of the item in the property grid using the following code:
UpdateConstraintsCategory() is just a switch that adds 3 more items depending on the type.
Its pretty slow switching tree nodes letting this code execute. Can anything be done to speed it up?
* I do get the errors I mentioned before:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ActiproSoftware.Windows.Controls.PropertyGrid.TreeListViewItem', AncestorLevel='1''. BindingExpression:Path=IsExpanded; DataItem=null; target element is 'TreeListViewToggleButton' (Name=''); target property is 'IsChecked' (type 'Nullable`1')
* I tried BeginUpdate and EndUpdate, but that didn't do anything.
* If I comment out the 8 or so lines where I add the items, the speed is good.
* If I only add the first 4 items, it is already pretty slow.
* I need to use this vs. SelectedObject because I need to be able to remove / add items dynamically.
[Modified at 04/21/2010 07:36 PM]
TreeViewItemEx tvi = (TreeViewItemEx)e.NewValue;
FieldProxy fp = (FieldProxy)tvi.Tag;
pgFields.Items.Clear();
PropertyGridCategoryItem ci1 = new PropertyGridCategoryItem();
ci1.DisplayName = "General";
pgFields.Items.Add(ci1);
ci1.Accessors.Add(new PropertyDescriptorDataAccessor(fp, "Name"));
ci1.Accessors.Add(new PropertyDescriptorDataAccessor(fp, "Description"));
ci1.Accessors.Add(new PropertyDescriptorDataAccessor(fp, "Cloneable"));
ci1.Accessors.Add(new PropertyDescriptorDataAccessor(fp, "ReadOnly"));
PropertyGridCategoryItem ci2 = new PropertyGridCategoryItem();
ci2.DisplayName = "Scripts";
pgFields.Items.Add(ci2);
ci2.Accessors.Add(new PropertyDescriptorDataAccessor(fp, "OnExtract"));
ci2.Accessors.Add(new PropertyDescriptorDataAccessor(fp, "OnVerify"));
ci2.Accessors.Add(new PropertyDescriptorDataAccessor(fp, "OnExport"));
PropertyGridCategoryItem ci3 = new PropertyGridCategoryItem();
ci3.DisplayName = "Constraints";
pgFields.Items.Add(ci3);
_category = ci3;
IPropertyDataAccessor accessor = new PropertyDescriptorDataAccessor(fp, "FieldType");
ci3.Accessors.Add(accessor);
UpdateConstraintsCategory((FieldType)accessor.Value);
Its pretty slow switching tree nodes letting this code execute. Can anything be done to speed it up?
* I do get the errors I mentioned before:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ActiproSoftware.Windows.Controls.PropertyGrid.TreeListViewItem', AncestorLevel='1''. BindingExpression:Path=IsExpanded; DataItem=null; target element is 'TreeListViewToggleButton' (Name=''); target property is 'IsChecked' (type 'Nullable`1')
* I tried BeginUpdate and EndUpdate, but that didn't do anything.
* If I comment out the 8 or so lines where I add the items, the speed is good.
* If I only add the first 4 items, it is already pretty slow.
* I need to use this vs. SelectedObject because I need to be able to remove / add items dynamically.
[Modified at 04/21/2010 07:36 PM]