HandyOrg / HandyOrg/HandyControl

Bug title 轮播控件Carousel绑定数据时异常问题

Open
#1,680 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
7.2k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

首先,非常感谢你们的付出,控件很好用,谢谢。在使用中,我发现轮播控件Carousel绑定数据后不会自动更新,需要每次数据更新完毕后调用hcCarousel.OnApplyTemplate()才能更新,但还是有点问题,OnApplyTemplate()后第一张图片显示的宽度少于设定的宽度,要切换到第二张图片后才会恢复正常。如果直接在XAML中写死Image,宽度是正常的,看下图。期待你们的回复

Steps to reproduce the bug

XAML 代码 显示有问题,后面有截图:
`<hc:Carousel x:Name="hcCarousel" ItemsSource="{Binding ImageList}" Interval="0:0:5" IsCenter="True" AutoRun="True" Width="380" Height="400" VerticalAlignment="Center">
hc:Carousel.ItemTemplate

<hc:SimplePanel Width="380">


</hc:SimplePanel>

    </DataTemplate>
</hc:Carousel.ItemTemplate>

</hc:Carousel> ViewModel代码: View.hcCarousel.PageIndex = 0;
View.hcCarousel.OnApplyTemplate();`

Expected behavior

No response

Screenshots

errImage
trueImage

第一个图片就是OnApplyTemplate()后第一张图片显示
正常宽度是第二张图片

NuGet package version

None

IDE

Visual Studio 2022

Framework type

No response

Windows version

No response

Additional context

VS 2022 .NET 9.0 HandyControl 3.5.1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Carousel behavior with the XAML and ViewModel code shown in the issue, focusing on ItemsSource updates and the first-image width after OnApplyTemplate(). Trace the Carousel control's data-refresh and template-layout behavior. Done means bound data updates automatically and the first image has the configured width without requiring a page switch.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.