locked
The itemGridView->SelectedItems->Size will be auto reduce after itemGridView->SelectAll(),it's correct behavior?

    Question

  • Hi,

    I used StorageDataSource and GetVirtualizedFilesVector sample to list my photos.

    But the itemGridView->SelectedItems->Size will be auto reduce after itemGridView->SelectAll(), why?

    is possible to avoid this behavior?

    Thursday, December 13, 2012 6:31 AM

Answers

  • Actually, the SelectedItems list is a vector, and you can add and remove stuff from it like any other vector.

    Andrea Mantler

    • Marked as answer by TonyChi Tuesday, October 8, 2013 8:03 AM
    Monday, December 17, 2012 7:03 AM

All replies

  • Hi,

    I cannot reproduce your issue?

    After select all the SelectedItems->Size is the same with items->Size. I tested with these codes.

    	int before=itemGridView->SelectedItems->Size;
    	itemGridView->SelectAll();
    	int after=itemGridView->SelectedItems->Size;
    	int count=itemGridView->Items->Size;

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 14, 2012 6:14 AM
  • I'm guessing you may have inadvertently added the same element more than once to SelectedItems.  It will still appear normal when you look at what is selected, but the count is higher than the actual number of distinct elements.  Is this what happened?

    Andrea Mantler

    Saturday, December 15, 2012 12:59 AM
  • Hi,

    My Mistake. I should be explain my test steps.

    First, i got the code about StorageDataSource and GetVirtualizedFilesVector sample (C++)

    and it will load my picture library, it have more than 2000 pics.

    Then, i add 2 buttons, that Button A & Button B.

    In Button A, I add the code

        itemGridView->SelectAll();
        int selCount = itemGridView->SelectedItems->Size;
        int totalCount = itemGridView->Size;


    In Button B, I add the code

        int selCount = itemGridView->SelectedItems->Size;

    In Test, I Click Button A, and i got that selCount value is same as totalCount. And then, i Click Button B, the selCount beginning redeuced.

    I guess its for release resource behavior, but is possible to avoid this behavior?

    PS: i have already google this problem, the key words are "gridview" "virtualization" "selectall"

    and got this http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/cdd41f1e-0ade-4679-9c05-d2313e6696c2/#0a990ba6-b7a3-4a4b-a47a-3a007b544a0d 

    The Select All Not actually "Select All", I guess is the same reason. But the sample that used JavaScript, is correct, the Select All can actually  select All.


    Monday, December 17, 2012 2:24 AM
  • I used sample code. And it will auto load my picture library.

    I only add code to get the count about select items.

    And the result is after select all operation, the select items count will auto reduced.

    Monday, December 17, 2012 2:30 AM
  • How annoying.  A work-around would be to have a boolean in your item data structure that keeps track of what is selected, and then query that list of items rather than the SelectedItems.

    Andrea Mantler

    Monday, December 17, 2012 3:59 AM
  • How annoying.  A work-around would be to have a boolean in your item data structure that keeps track of what is selected, and then query that list of items rather than the SelectedItems.

    Andrea Mantler

    Hi Andrea Mantler,

    I think it should be workable. But it still have a problem.

    Now, I can got the correct select items, but the UI, the Grid View that link with  fileInformationFactory->GetVirtualizedFilesVector() still display wrong selected result. And i guess i can't change the selected items list. 

    Monday, December 17, 2012 5:55 AM
  • Actually, the SelectedItems list is a vector, and you can add and remove stuff from it like any other vector.

    Andrea Mantler

    • Marked as answer by TonyChi Tuesday, October 8, 2013 8:03 AM
    Monday, December 17, 2012 7:03 AM
  • Actually, the SelectedItems list is a vector, and you can add and remove stuff from it like any other vector.

    Andrea Mantler

    Hi Andrea Mantler,

    Actually, i have already try below code.

       itemGridView->SelectedItems->Clear();
        for(int i = 0; i<itemGridView->Items->Size; i++)
        {
            itemGridView->SelectedItems->Append(itemGridView->Items->GetAt(i));
        }
    		
        int selCount = itemGridView->SelectedItems->Size;

    It only workable when scroll bar at the beginning position, and don't change any selected item.

    But the UI still can't sync with selected items too.

    If change the scroll bar's position, or change selected items. Then try to get the select items num, the num  will reduce again.


    Monday, December 17, 2012 8:24 AM
  • Hi,

    I tested A and B button, but I still cannot reproduce this issue. Maybe you can try update the Visual Studio to SP1 or change another machine to test this.

    Another temp solution, we can store it as a glob value or before we get SelectedItems->Size , we can select all again.

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 18, 2012 5:51 AM
  • Hi, Jesse,

    Thanks for your reply.

    I have already change another machine to try this,  unfortunately, the problem still exist.

    And my VS is VS ultimate 2012 Version 11.0.50727.1, so, it's already have SP1 now? I will try to update it.

    In my option, this problem root cause is about release system resource. So it need more than 2000 pics in Picture Library in my test environment, may be your machine is powerful. I guess may be need more pics for test.

    For this problem, it's easy detect by UI display. If select all is correct, after move the scroll bar,  all selected items still selected. But in my test environment, move the scroll bar, some pics are selected, another's not. 

    Tuesday, December 18, 2012 6:43 AM
  • Hi Jesse,

     I have already update the VS, now the version is 11.0.51106.01 Update 1. i only got this, not SP1 package. Could your give us a Sp1 download link?

     And i try again the sample by this new environment, the problem still exist.

    PS: I try the  StorageDataSource and GetVirtualizedFilesVector sample (C++).

    Wednesday, December 19, 2012 12:55 PM