locked
GridView - Non selected item becomes selected when using Gridview.ItemsPanel

    שאלה

  • Hello!

    If I have a GridView with items in it, when if I select an item and move another item in front of the selected item, they both become selected.

    This does not happen if an item is not selected prior to re-arranging the item.

    This only happens if you use Gridview.ItemsPanel to control how the items are arranged.  This seems like a bug.

    The simplest way to reproduce this bug is by creating a page/usercontrol with the following XAML:

    <Grid>
            <GridView 
                    CanDragItems="True"
                    CanReorderItems="True"
                    AllowDrop="True"
                    SelectionMode="Multiple"
                >
                <GridView.Items>
                    <Rectangle Fill="Red" Height="500" Width="100" />
                    <Rectangle Fill="Blue" Height="500" Width="100" />
                    <Rectangle Fill="Yellow" Height="500" Width="100" />
                    <Rectangle Fill="Green" Height="500" Width="100" />
                    <Rectangle Fill="Red" Height="500" Width="100" />
                    <Rectangle Fill="Blue" Height="500" Width="100" />
                    <Rectangle Fill="Yellow" Height="500" Width="100" />
                    <Rectangle Fill="Green" Height="500" Width="100" />
                </GridView.Items>
                <!-- The Gridview.ItemsPanel causes a non selected item to APPEAR selected after moving it in front of a selected item-->
                <GridView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel  Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </GridView.ItemsPanel>
            </GridView>
        </Grid>

    The strange thing is that if you run the debugger and look at the item collection, the item that you moved isn't marked as selected, nor is it in the SelectedItems collection.  It only appears to be selected visually.

    If you remove the Gridview.ItemsPanel node, the bug does not occur.

    Any advice? Bug confirmation?

    Thanks,

    Jason Grimme


    • נערך על-ידי Jason Grimme יום רביעי 11 אפריל 2012 19:13 Clarification
    יום רביעי 11 אפריל 2012 19:13

כל התגובות

  • Bumping.  I'd like to know if this is a bug or if my implementation is incorrect.

    Any advice?  Thanks.

    יום שני 16 אפריל 2012 14:54
  • I'm not sure of the cause but I saw something like this when refreshing from the AppBar.  I was able to work around the problem by adding a blank gridview item header.    
    • נערך על-ידי TravJ יום שלישי 19 יוני 2012 18:01
    יום שלישי 19 יוני 2012 18:00
  • When you say you move another item in front of the selected item -- is that via reordering via drag and drop?

    -mark
    Program Manager
    Microsoft
    This post is provided "as-is"
    יום שלישי 19 יוני 2012 19:07