This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have a class which contains a collection of structs; when the user expands the struct to modify it's members they get a red outline on the value & the underlying data is not updated. Upon looking into the issue I noticed the property grid was throwing the following exception: A first chance exception of type 'System.Reflection.TargetParameterCountException' occurred in mscorlib.dll A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll System.Windows.Data Error: 8 : Cannot save value from target back to source. BindingExpression:Path=Value; DataItem='ObjectWrapper`1' (HashCode=34742292); target element is 'TextBox' (Name=''); target property is 'Text' (type 'String') TargetParameterCountException:'System.Reflection.TargetParameterCountException: Parameter count mismatch. at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) at #c.#Tl.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) at Mindscape.WpfPropertyGrid.ObjectWrapper.get_RawValue() at Mindscape.WpfPropertyGrid.ObjectWrapper.#Er(Object value) at Mindscape.WpfPropertyGrid.ObjectWrapper.#qN(Object value) at Mindscape.WpfPropertyGrid.ObjectWrapper.#Er(Object value) at Mindscape.WpfPropertyGrid.ObjectWrapper`1.set_Value(T value)' I've attached a sample. |
|
|
Hello Mike, Thank you for letting us know about this issue and for the repro sample. I've committed a candidate fix which will be included in nightly builds dated 27 July 2010 and above (available from about 1500 GMT). Please give it a go and let us know if you still see problems. |
|
|
Thanks Ivan, This fixes the sample & helps with the production code. Though I'm still having an issue in that. instead of an observable colleciton we have a custom collection that implements INotifyCollectionChanged. When the indexed setter (this[int index]) is called we raise: INotifyCollectionChanged.CollectionChanged(this, gcnew NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction::Replace, item, olditem, index)); Is this the event you are watching in your fix or should we be raising a differenct event(s)?
|
|
|
Just noticed I poseted the incomplete version of that. That's the set up, here's the problem we're running into: The nightly build removes the exception & updates the data in the custom collection when you edit the struct or its members. But the UI for either the struct (custom editor) or the memebers, which ever one you did not make the edit on, is not updated to reflect the new value. Any thoughts?
|
|
|
Replace should be fine: that's the same as what ObservableCollection does. The fix didn't change what events we watch, it just corrected an internal assumption that expandable structs would always be properties rather than collection elements. What's the nature of the issue you're seeing? Can you provide me with a repro? Thanks! |
|
|
Thinking about this a bit further, I think we may be relying on ObservableCollection's IPropertyChanged support -- in addition to the CollectionChanged event, it raises PropertyChanged events for Item (or Item[]) when an item is replaced. Could you try getting your custom collection to raise that? |
|
|
Implementing INotifyPropertyChanged fixes it; thanks again! |
|