【问题标题】:WinUI Community Toolkit Carousel not displaying itemsWinUI Community Toolkit Carousel not displaying items
【发布时间】:2022-12-01 23:10:58
【问题描述】:

I have a WinUI 3 project in which I installed the Windows Community Toolkit for WinUI (the common, WinUI, WinUI UI and Layout Controls packages) and I use the Carousel from the CommunityToolkit.WinUI.UI.Controls.Layout package. However, when I add any items to it, they simply do not show up on the carousel. I set the background colour to red to confirm the carousel does indeed show and the result sure is a massive red box, but no images on it. I followed the example for UWP that can be found here. I know UWP is obviously not the same as WinUI, but they are certainly similar, and I couldn't find an example for WinUI.

The source code can be found here (the repo is on a private server, so I cannot share that link).

The Carousel control can be found in the MainWindow, the items list contains an instance of ChessClientGame and CheckersClientGame, but neither show up in the carousel, even though the source of the image in the carousel is bound to the IconPath property which is set to a valid image resource in both games.

I tried both binding the source to IconPath property and setting the Source directly to an image (such as /Resources/Images/GameIcons/ChessIcon.png), but in neither case anything actually showed up in the carousel. What I expected to happen was seeing two images in the carousel that I could select.

【问题讨论】:

  • Can you post code around the Carousel? And are you sure your images are loaded?

标签: c# winui-3 windows-community-toolkit


【解决方案1】:

Turns out I simply did not set the build action of the images to 'Content'. Doing so fixed it, so nothing is wrong with the carousel code.

【讨论】:

    猜你喜欢
    • 2014-07-20
    • 1970-01-01
    • 2015-09-27
    • 2022-08-04
    • 1970-01-01
    • 1970-01-01
    • 2015-04-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多