michaellperry / Assisticant

MIT License
36 stars 19 forks source link

Binding to indexers works but throws errors.. #34

Open sicsix opened 4 years ago

sicsix commented 4 years ago

I'm dynamically creating columns as required in my program, and binding cell values and properties etc on my datagrid to indexes into an ObservableList, accessed through an IEnumerable.

Works fine until the observable list is modified, then any time I change the list or reload the data from the list I get this error:

System.Windows.Data Error: 17 : Cannot get 'Item[]' value (type 'Object') from 'IsDirty' (type 'ObservableCollection1'). BindingExpression:Path=IsDirty[0]; DataItem='PlatformProxy1' (HashCode=6556909); target element is 'DataGridCell' (Name=''); target property is 'NoTarget' (type 'Object') ArgumentOutOfRangeException:'System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

Strangely, the error does not exist prior to modifying the data in the list, and is 100 percent repeatable, and occurs across multiple bindings of different types.

Stranger still, the view still looks correct. Just throws a ton of errors in the background.

For example, with this IsDirty[] collection, setting the values all to true before loading up the data, no issues. Setting the value to true again causes no errors (probably doesn't raise an event internally to Assisticant?)

However, if the values start at false, and I change any of them to true, each element will throw an error every time it is changed or reloaded, but will still display correctly (bolded text through converter).

sicsix commented 4 years ago

I've tried using ILists<>, there are zero errors but the binding never updates.

I guess I should note that the underlying lists are being modified in the code through indexers.

michaellperry commented 4 years ago

I haven't used dynamic column binding in quite some time. Searching on this particular warning shows that it has cropped up in the last few years. I'm sure there is something that Assisticant's PlatformProxy does that is aggressive toward dynamic property detection.

For the short term, I would suggest declaring explicit data grid columns and binding expressions. It might take me a while to put together a repro and track down the issue.