GridView - item remove from source collation not shown on Windows 11

60856927 66 Reputation points
2024-09-11T10:18:06.42+00:00

I am using GridView to implement list of games with cover arts. All grid items are binded to ObservableCollection by ItemsSource="{x:Bind StoreInfo.GameInfos}"

I added an option to update the game cover art. To show updated item in live I remove the item from the ObservableCollection and add it back like following

var index = store.GameInfos.IndexOf(gameInfo);
store.GameInfos.Remove(gameInfo);
gameInfo.ImagePath = imagePath;
store.GameInfos.Insert(index, gameInfo);

On Windows 10 it works well but on Windows 11 it doesn't work - the item is not removed. User must refresh the page to see updated result. I don't want to add a logic to refresh entire page in case of Windows 11. Please help to find a solution to make it working on Windows 11 like it works on Windows 10.

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. Darshida Das 15 Reputation points
    2024-09-11T14:15:46.2+00:00
    # Create a new WPF window
    
    <Page
        x:Class="GameCoverArtApp.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:GameCoverArtApp"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
        <Grid>
            <GridView ItemsSource="{x:Bind StoreInfo.GameInfos}">
                <GridView.ItemTemplate>
                    <DataTemplate x:DataType="local:GameInfo">
                        <StackPanel>
                            <Image Source="{x:Bind ImagePath}" Height="200" Width="150"/>
                            <TextBlock Text="{x:Bind Name}" />
                        </StackPanel>
                    </DataTemplate>
                </GridView.ItemTemplate>
            </GridView>
            <Button Content="Update Cover Art"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Top"
                    Click="UpdateCoverArt_Click" />
        </Grid>
    </Page>
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.