Skip to content

How to change NavigationViewItem image content without flickering #7039

@rcohn

Description

@rcohn

Hello -

I am building a WinUI3 desktop app with WindowsAppSDK 1.0 and need to change an image in the Content section of a NavigationViewItem dynamically. I have been able to change the image by using a data class that derives from INotifyPropertyChanged where the asset path for the image is changed under program logic. That works OK.

The Content of the item is a simple horizontal StackPanel with these elements: Image1, TextBlock, Image2
Image1 and TextBlock are static; I'm only changing Image2.

But when I change Image2, the entire NavigationViewItem flickers. It seems the entire item layout is being regenerated when Image2 is changed.

I have thought of perhaps using a layout image over the item, but that's kind of kludgy and I'm not clear on how such a layout could be positioned properly. Another idea I thought of was to somehow use storyboarding. Both of these are challenging. Was hoping for something simpler that I hadn't thought of.

Thanks for any suggestions you can provide.

Robert

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions