ICollectionView weirdness (maybe one for Jaime or someone Microsoft) HELP

198 views
Skip to first unread message

Sacha Barber

unread,
Apr 20, 2009, 6:50:39 AM4/20/09
to wpf-di...@googlegroups.com
Hello all

I am having an issue with ICollectionView over a collection. I am attempting to move the current item, using the MoveToCurrentPosition() method, as you can see in the attached screen shot, I am attempting to move it to position 0. Now you can see a break point just after that line, and low and behold the ICollectionView.CurrentPosition is 7. What the Hell.

Any ideas??

I assume that the MoveToCurrentPosition() method doesn't use Equals? Does it need to know about Comparison, should I need to implement IComparable etc etc

 

 

Any help you could give me would be greatly appreciated. Thanks


From: Sacha Barber
Sent: 20 April 2009 09:00
To: Richard King
Subject: FW: UI release notes, that may help you write release notes

 

 

 

From: Sacha Barber
Sent: 20 April 2009 08:59
To: Amy Amer; Henry McKeon; Martyn Wells
Subject: UI release notes, that may help you write release notes

 

Hello all (welcome back to some of you).

 

It was a strange iteration this time, as it was shorter than usual.

 

The UI has not changed that much outwardly, but here is a list of what has been done this iteration:

 

-          Add working day validation (validation only, disabling of dates based on working day still needs doing), this was resulting in a broken build for quite a while, so that was a nice one to fix.

-          Helping Martin with fixing popups

-          Writing document for future screen development, so we do not end up doing code for popups like we just did (they were incorrect)

-          Advanced search had a major problem with its overall structure, which is a limitation of GNRSQL, which Rich King and I have now fixed

-          Advanced search had the possibility to leak memory as we were creating dynamic code at runtime which was loaded into the  current codebase (at runtime), which was bad. So we fixed this to load it into its own codebase space, run it and then unload it.

-          Advanced search is loading searches up/saving to a lighter weight persistable tree, which we are now in a position to start storing to the DB instead of RAM, if our proposal is agreed with the team (see Rich Kings email)

 

We have made some real progress, it is just that it is not that visible this time. I just wanted to let you know

 

 

So there you have it


This email and any attachments are confidential and may be privileged and are intended solely for the use of the named recipients. If you are not the intended recipient, it is prohibited and may be unlawful to use or copy this email for any purpose or disclose its contents. The views expressed may not be the views of TTT Moneycorp Ltd and should not be relied upon. If you have received this communication in error, please notify TTT at discl...@ttt.co.uk immediately by email or by telephone (+44 20 7823 7700) before deleting it. Please be aware that emails and attachments may contain viruses. Thank you for your co-operation.

TTT Moneycorp Limited is a company registered in England under registration number 738837. Its registered office address is 2 Sloane Street, London, SW1X 9LA.


Windows Live Messenger just got better. Find out more!

Eric Burke

unread,
Apr 20, 2009, 11:46:12 AM4/20/09
to wpf-di...@googlegroups.com
The inline image in your email didn't come through, can you resend?
 
I don't think IComparable matters in this case since it's an index and not comparing objects.
 
Questions:
 
+ Is this a ListCollectionView?
 
+ has the view been refreshed at least once?
+ is something handling CurrentChanging and setting e.Cancel = true?
 
+ does MoveCurrentToPosition() return true or false? [that shouldn't affect the current position, just curious]
 
+ this line inside ListCollectionView.MoveCurrentToPosition():
 
  object newItem = ((0 <= position) && (position < this.InternalCount)) ? this.InternalItemAt(position) : null;
 
drill into the ICV and see if InternalCount == 0.
+ also have a look at ListCollectionView.InternalItemAt and see if that could be failing somewhere.


From: Sacha Barber <sacha...@hotmail.com>
To: "wpf-di...@googlegroups.com" <wpf-di...@googlegroups.com>
Sent: Monday, April 20, 2009 6:50:39 AM
Subject: [WPF Disciples] ICollectionView weirdness (maybe one for Jaime or someone Microsoft) HELP

Sacha Barber

unread,
Apr 20, 2009, 12:15:27 PM4/20/09
to wpf-di...@googlegroups.com
I can asnwer some of this right now

- It is a ListCollectionView
- View has been created only once like CollectionViewSource.GetDefaultView(Somelist), and then the CurrentChanged event
   hooked up
- e.Cancel is never getting set


As for the rest, Ill have to try it out



Thanks for these ideas Eric Ill have a look into this tomorrow for sure.

Thanks



Date: Mon, 20 Apr 2009 08:46:12 -0700
From: ebu...@yahoo.com
Subject: [WPF Disciples] Re: ICollectionView weirdness (maybe one for Jaime or someone Microsoft) HELP
To: wpf-di...@googlegroups.com

Share your photos with Windows Live Photos – Free. Try it Now!

Sacha Barber

unread,
Apr 20, 2009, 12:19:25 PM4/20/09
to wpf-di...@googlegroups.com
Here is the image this time



Date: Mon, 20 Apr 2009 08:46:12 -0700
From: ebu...@yahoo.com
Subject: [WPF Disciples] Re: ICollectionView weirdness (maybe one for Jaime or someone Microsoft) HELP
To: wpf-di...@googlegroups.com

Surfing the web just got more rewarding. Download the New Internet Explorer 8
Weird.png

Eric Burke

unread,
Apr 20, 2009, 12:31:50 PM4/20/09
to wpf-di...@googlegroups.com
It appears from the code for MoveCurrentToPosition(X) that the only ways it will fail are:
 
+ X == theView.CurrentPosition (it does not)
 
+ CollectionView.IsCurrentInSync == true (not sure).  This could be the culprit if you've added the same item twice, and one happens to be at position 0 and one at position 7.
 
protected bool IsCurrentInSync
{
    get
    {
        if (this.IsCurrentInView)
        {
            return (this.GetItemAt(this.CurrentPosition) == this.CurrentItem);
        }
        return (this.CurrentItem == null);
    }
}
 
+ the item at position X is the CollectionView.NewItemPlaceholder
 
+ CollectionView.OKToChangeCurrent returns false (ie., someone handled CurrentChanging and set e.Cancel)
 
 
 
Here's the code for MoveCurrentToPosition() from Reflector:
public virtual bool MoveCurrentToPosition(int position)
{
    this.VerifyRefreshNotDeferred();
    if ((position < -1) || (position > this.Count))
    {
        throw new ArgumentOutOfRangeException("position");
    }
    IEditableCollectionView view = this as IEditableCollectionView;
    if (((view == null) || (((position != 0) || (view.NewItemPlaceholderPosition != NewItemPlaceholderPosition.AtBeginning)) && ((position != (this.Count - 1)) || (view.NewItemPlaceholderPosition != NewItemPlaceholderPosition.AtEnd)))) && (((position != this.CurrentPosition) || !this.IsCurrentInSync) && this.OKToChangeCurrent()))
    {
        bool isCurrentAfterLast = this.IsCurrentAfterLast;
        bool isCurrentBeforeFirst = this.IsCurrentBeforeFirst;
        this._MoveCurrentToPosition(position);
        this.OnCurrentChanged();
        if (this.IsCurrentAfterLast != isCurrentAfterLast)
        {
            this.OnPropertyChanged("IsCurrentAfterLast");
        }
        if (this.IsCurrentBeforeFirst != isCurrentBeforeFirst)
        {
            this.OnPropertyChanged("IsCurrentBeforeFirst");
        }
        this.OnPropertyChanged("CurrentPosition");
        this.OnPropertyChanged("CurrentItem");
    }
    return this.IsCurrentInView;
}

 

Sent: Monday, April 20, 2009 12:15:27 PM

Subject: [WPF Disciples] Re: ICollectionView weirdness (maybe one for Jaime or someone Microsoft) HELP

I can asnwer some of this right now

- It is a ListCollectionView
- View has been created only once like CollectionViewSource.GetDefaultView(Somelist), and then the CurrentChanged event
   hooked up
- e.Cancel is never getting set


As for the rest, Ill have to try it out



Thanks for these ideas Eric Ill have a look into this tomorrow for sure.

Thanks


Sacha Barber

unread,
Apr 20, 2009, 3:53:46 PM4/20/09
to wpf-di...@googlegroups.com
Cheers for all this Eric, Ill do some heavy duty digging tomorrow, its just frustrating when you have to get something done.


Date: Mon, 20 Apr 2009 09:31:50 -0700
Reply all
Reply to author
Forward
0 new messages