What changed in the DataGrid that means it won't work anymore?
Posted
by Jeff Yates
on Stack Overflow
See other posts from Stack Overflow
or by Jeff Yates
Published on 2009-07-12T07:12:44Z
Indexed on
2010/03/12
19:27 UTC
Read the original article
Hit count: 219
datagrid
|silverlight-3.0
I have a Silverlight app with a DataGrid containing some custom columns and all was working well. Then I updated to Silverlight 3 tools for VS 2008 SP1 and rebuilt it. Now it has the following problems:
Rows aren't added when the collection is modified. The ItemsSource property is (and always has been) set to an ObservableCollection instance, which notifies when its contents change. This worked fine for Silverlight 2. However, in Silverlight 3 to get this working at all, I now have to null and then re-set ItemsSource - this seems like I'm hiding a bigger issue but I can't work out what that might be.
I cannot select a row or a cell anymore. If I'm lucky, I can select one whole row before it stops working.
I can't edit anything. I suspect this is related to the previous point.
I'll post some source when I am able, but first I have to strip it down to the bare minimum. In the meantime, I was hoping someone might have some idea of what may be going on here. My gut feeling on the second two points is that my bindings are no longer working, but that's just a guess and if it is the case, I have no idea which ones.
Thanks for any help anyone might be able to provide.
Update
So, I finally reduced my problem down to a simple works/doesn't work comparison. The problem seems to occur if I override Equals
in my element type. As soon as I do that, something happens strangely in the ObservableCollection
that contains that type, it seems, and my application breaks. To make it more interesting, there is a check to make sure that duplicate items don't even get close to being added to the collection. I don't exactly know why ObservableCollection
needs to compare equality when inserting items (the stack trace indicates it is using IndexAt
) but this seems to cause the issue.
So, any thoughts?
© Stack Overflow or respective owner