Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlipView displays only the first 4 items in a loop #10134

Closed
kaismic opened this issue Nov 3, 2024 · 2 comments
Closed

FlipView displays only the first 4 items in a loop #10134

kaismic opened this issue Nov 3, 2024 · 2 comments
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners

Comments

@kaismic
Copy link

kaismic commented Nov 3, 2024

Describe the bug

When FlipView.ItemTemplate contains a custom view class which is derived from a FrameworkElement, the FlipView only displays the first 4 items and loops through them.

Sometimes even the same image appears twice in a row when scrolling back.

Specifically:

ImageCollectionPanel.xaml

<Grid>
    <Image>
        <Image.Source>
            <BitmapImage UriSource="{x:Bind ImageInfo.ImageFilePath}"/>
        </Image.Source>
    </Image>
</Grid>

This works fine:

    <FlipView ItemsSource="{x:Bind ViewModel.ImageCollectionPanelVMs}">
        <FlipView.ItemTemplate>
            <DataTemplate x:DataType="vms:ImageCollectionPanelVM">
                <Image>
                    <Image.Source>
                        <BitmapImage UriSource="{x:Bind ImageInfo.ImageFilePath}"/>
                    </Image.Source>
                </Image>
            </DataTemplate>
        </FlipView.ItemTemplate>
    </FlipView>

But this does not:

    <FlipView ItemsSource="{x:Bind ViewModel.ImageCollectionPanelVMs}">
        <FlipView.ItemTemplate>
            <DataTemplate x:DataType="vms:ImageCollectionPanelVM">
                <vpviews:ImageCollectionPanel ImageInfo="{x:Bind ImageInfo}"/>
            </DataTemplate>
        </FlipView.ItemTemplate>
    </FlipView>

Steps to reproduce the bug

  1. Clone the Demo, run it then close the app.
  2. Copy and paste the example image files in images folder to C:\%USERPROFILE%\AppData\Local\Packages\ce327634-4e8f-4be9-ada0-51371298762e_90dh4avacgaqr\LocalCache\Local.
  3. Rerun the app and only the first 4 images will display in a loop.

Expected behavior

FlipView should show all the images as I flip through the pages.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.6.1: 1.6.240923002

Windows version

Windows 10 (20H2): Build 19042

Additional context

it probably won't matter but:
My .csproj contains

    <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
    <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
@kaismic kaismic added the bug Something isn't working label Nov 3, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Nov 3, 2024
@karkarl karkarl added needs-author-feedback Asked author to supply more information. and removed needs-triage Issue needs to be triaged by the area owners labels Nov 7, 2024
@marcelwgn
Copy link
Collaborator

I think this might need an issue with how the property ImageInfo is defined in your UserControl ImageCollectionPanel. Can you try implementing it as a DependencyProperty and use BindingMode.OneWay inside ImageCollectionPanel.xaml and see if it still repros?

@kaismic
Copy link
Author

kaismic commented Nov 8, 2024

I think this might need an issue with how the property ImageInfo is defined in your UserControl ImageCollectionPanel. Can you try implementing it as a DependencyProperty and use BindingMode.OneWay inside ImageCollectionPanel.xaml and see if it still repros?

Yep, it worked. Thank you very much!

ImageCollectionPanel.xaml

<Grid>
    <Image>
        <Image.Source>
            <BitmapImage UriSource="{x:Bind ImageInfo.ImageFilePath, Mode=OneWay}"/>
        </Image.Source>
    </Image>
</Grid>

ImageCollectionPanel.xaml.cs

    public sealed partial class ImageCollectionPanel : Grid {

        public static readonly DependencyProperty ImageInfoProperty = DependencyProperty.Register(
            nameof(ImageInfo),
            typeof(ImageInfo),
            typeof(ImageCollectionPanel),
            null
        );

        public ImageInfo ImageInfo {
            get => (ImageInfo)GetValue(ImageInfoProperty);
            set => SetValue(ImageInfoProperty, value);
        }

        //public ImageInfo ImageInfo { get; set; }

        public ImageCollectionPanel() {
            InitializeComponent();
        }
    }

@kaismic kaismic closed this as completed Nov 8, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added needs-triage Issue needs to be triaged by the area owners and removed needs-author-feedback Asked author to supply more information. labels Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

No branches or pull requests

3 participants