none
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

כל התגובות