Updating Observablecollection without grid refreshing.

Oct 7, 2009 at 1:07 PM

I have my datgrid's (latest release) itemsource binded to a observablecollection. Every 5 secs my client app resceives a list from the server which i use to update the observable collection. The problem is that when it updates the grid seems to reset (if details is open when i update the details collapses, if i have an item selected it will un-select)

Here is the code that i am using to update my observable collection:

    Private Sub creategriddata()
        Dim svc As New ServiceReference1.Client

        Try
            svc.Open()
            Dim full = svc.dblinktest(My.Settings.sysselectedstack).ToList()
            svc.Close()

            Dim removeitems = localobservablecollection.Except(full).ToList()
            Dim additems = full.Except(localobservablecollection).ToList()

            For Each document In additems

                localobservablecollection.Add(document)
            Next


            For Each document In removeitems

                localobservablecollection.Remove(document)
            Next

        Catch ex As Exception

        End Try
    End Sub
I used this on Exceeds wpf datagrid and it worked fine (i am no longer using xceeds) is there a better way to update the observable collection without causing the grid to sort of rest?
Thanks
Oct 7, 2009 at 10:50 PM
I have a similar problem. See my post *How to freeze expanded Rowdetails*

Thanks,

Bill

On 10/7/2009 7:07 AM, whittssg wrote:
>
>
> From: whittssg
>
> I have my datgrid's (latest release) itemsource binded to a
> observablecollection. Every 5 secs my client app resceives a list from
> the server which i use to update the observable collection. The problem
> is that when it updates the grid seems to reset (if details is open when
> i update the details collapses, if i have an item selected it will
> un-select)
>
> Here is the code that i am using to update my observable collection:
>
> Private Sub creategriddata()
> Dim svc As New ServiceReference1.Client
>
> Try
> svc.Open()
> Dim full = svc.dblinktest(My.Settings.sysselectedstack).ToList()
> svc.Close()
>
> Dim removeitems = localobservablecollection.Except(full).ToList()
> Dim additems = full.Except(localobservablecollection).ToList()
>
> For Each document In additems
>
> localobservablecollection.Add(document)
> Next
>
>
> For Each document In removeitems
>
> localobservablecollection.Remove(document)
> Next
>
> Catch ex As Exception
>
> End Try
> End Sub
> I used this on Exceeds wpf datagrid and it worked fine (i am no longer using xceeds) is there a better way to update the observable collection without causing the grid to sort of rest?
>
> Thanks
>
> Read the full discussion online
> <http://wpf.codeplex.com/Thread/View.aspx?ThreadId=71235&ANCHOR#Post242917>.
>
> To add a post to this discussion, reply to this email
> ([email removed]
> <mailto:[email removed]?subject=[wpf:71235]>)
>
> To start a new discussion for this project, email
> [email removed] <mailto:[email removed]>
>
> You are receiving this email because you subscribed to this discussion
> on CodePlex. You can unsubscribe or change your settings
> <https://wpf.codeplex.com/subscriptions/thread/project/edit> on
> codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any
> posts to this discussion will also be available online at codeplex.com
>