xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

[Bug] WPF: ListView with HasUnevenRows enabled doesn't update itself when Label in ViewCell wraps text. #13952

Closed cdytoby closed 1 year ago

cdytoby commented 3 years ago

Description

ListView with HasUnevenRows enabled doesn't update itself when Label in ViewCell wraps text automatically.

There is similar report in other ticket: https://github.com/xamarin/Xamarin.Forms/issues/1326
That ticket seems fixed for Android or iOS (I haven't tested yet), but this exact issue happens in WPF.

Steps to Reproduce

  1. Create ListView in XAML file, and create corresponding ViewModel for it.
  2. My List View code: (I trimed out other grid columns for shorter code)
<ListView
            Grid.Row="1"
            Margin="0,0,0,20"
            HasUnevenRows="True"
            ItemsSource="{Binding noteList}">

            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition
                                    Width="50" />
                                <ColumnDefinition
                                    Width="*" />
                                <ColumnDefinition
                                    Width="50" />
                                <ColumnDefinition
                                    Width="50" />
                            </Grid.ColumnDefinitions>

                            <!--Main Content-->
                            <StackLayout
                                Grid.Column="1"
                                Padding="0,10,0,10">
                                <Label
                                    Grid.Row="0"
                                    Text="{Binding createTime}"
                                    TextType="Text"
                                    FontSize="10" />
                                <Label
                                    Grid.Row="1"
                                    Text="{Binding content}"
                                    TextType="Text"
                                    FontSize="15" 
                                    LineBreakMode="WordWrap"/>
                            </StackLayout>

                        </Grid>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>

        </ListView>
  1. Run on windows.

Expected Behavior

Something close to this: image

Actual Behavior

image

Basic Information

Environment

Show/Hide Visual Studio info ``` Microsoft Visual Studio Community 2019 版本 16.8.6 VisualStudio.16.Release/16.8.6+31019.35 Microsoft .NET Framework 版本 4.8.04084 已安装的版本: Community Visual C++ 2019 00435-60000-00000-AA059 Microsoft Visual C++ 2019 ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools ASA Service Provider 1.0 ASP.NET and Web Tools 2019 16.8.560.26713 ASP.NET and Web Tools 2019 ASP.NET Core Razor Language Services 16.1.0.2052803+84e121f1403378489b842e1797df2f3f5a49ac3c Provides languages services for ASP.NET Core Razor. ASP.NET Web Frameworks and Tools 2019 16.8.560.26713 更多信息,请访问 https://www.asp.net/ Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer. Azure Data Lake Tools for Visual Studio 2.6.1000.0 Microsoft Azure Data Lake Tools for Visual Studio Azure Functions and Web Jobs Tools 16.8.560.26713 Azure Functions and Web Jobs Tools Azure Stream Analytics Tools for Visual Studio 2.6.1000.0 Microsoft Azure Stream Analytics Tools for Visual Studio Azure 应用服务工具 3.0.0 版 16.8.560.26713 Azure 应用服务工具 3.0.0 版 C# 工具 3.8.0-5.20604.10+9ed4b774d20940880de8df1ca8b07508aa01c8cd IDE 中使用的 C# 组件。可能使用其他版本的编译器,具体取决于你的项目类型和设置。 Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Fabric.DiagnosticEvents 1.0 Fabric 诊断事件 IntelliCode 扩展 1.0 IntelliCode Visual Studio 扩展详细信息 Microsoft Azure HDInsight Azure Node 2.6.1000.0 HDInsight Node under Azure Node Microsoft Azure Hive Query Language Service 2.6.1000.0 Language service for Hive query Microsoft Azure Stream Analytics Language Service 2.6.1000.0 Language service for Azure Stream Analytics Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30924.1 Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual C++ 向导 1.0 Microsoft Visual C++ 向导 Microsoft Visual Studio VC 软件包 1.0 Microsoft Visual Studio VC 软件包 Mono Debugging for Visual Studio 16.8.43 (00471f8) Support for debugging Mono processes with Visual Studio. NuGet 包管理器 5.8.1 Visual Studio 中的 NuGet 包管理器。有关 NuGet 的详细信息,请访问 https://docs.nuget.org/ ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info SQL Server Data Tools 16.0.62102.01130 Microsoft SQL Server Data Tools ToolWindowHostedEditor 1.0 Hosting json editor into a tool window TypeScript Tools 16.0.21016.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic 工具 3.8.0-5.20604.10+9ed4b774d20940880de8df1ca8b07508aa01c8cd IDE 中使用的 Visual Basic 组件。可能使用其他版本的编译器,具体取决于你的项目类型和设置。 Visual F# Tools 16.8.0-beta.20507.4+da6be68280c89131cdba2045525b80890401defd Microsoft Visual F# Tools Visual Studio Code 调试适配器主机包 1.0 用于在 Visual Studio 中托管 Visual Studio Code 调试适配器的互操作层 Visual Studio Container Tools Extensions 1.0 查看、管理和诊断 Visual Studio 中的容器。 Visual Studio Tools for CMake 1.0 Visual Studio Tools for CMake Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers Visual Studio Tools for Kubernetes 1.0 Visual Studio Tools for Kubernetes VisualStudio.DeviceLog 1.0 有关我的包的信息 VisualStudio.Foo 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio Xamarin 16.8.000.262 (d16-8@4d60f9c) 用于启用 Xamarin.iOS 和 Xamarin.Android 的开发的 Visual Studio 扩展。 Xamarin Designer 16.8.0.507 (remotes/origin/d16-8@e87b24884) 用于在 Visual Studio 中启用 Xamarin Designer 工具的 Visual Studio 扩展。 Xamarin Templates 16.8.112 (86385a3) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 11.1.0.26 (d16-8/a36ce73) Xamarin.Android Reference Assemblies and MSBuild support. Mono: 5e9cb6d Java.Interop: xamarin/java.interop/d16-8@79d9533 ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000 SQLite: xamarin/sqlite/3.32.1@1a3276b Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-8@2fb1cbc Xamarin.iOS and Xamarin.Mac SDK 14.10.0.4 (5a05865f6) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support. 适用于 Visual Studio 的 Microsoft Azure Service Fabric 工具 16.0 适用于 Visual Studio 的 Microsoft Azure Service Fabric 工具 适用于 Visual Studio 的 Microsoft 持续交付工具 0.4 从 Visual Studio IDE 内简化 Azure DevOps 管道配置。 通用 Azure 工具 1.10 通过 Azure 移动服务和 Microsoft Azure Tools 提供通用服务。 用于容器的 Microsoft Visual Studio Tools 1.1 在目标环境中开发、运行、验证 ASP.NET Core 应用程序。按 F5,应用程序经调试后直接进入容器,或者按 Ctrl+F5 可编辑和刷新应用,无需重新生成容器。 ```

Build Logs

Screenshots

Reproduction Link

Workaround

jfversluis commented 1 year ago

Taking into consideration the remaining lifetime of Xamarin.Forms, the platform this is about, the age of this issue and the traction this issue has seen I think it's unlikely that this will get fixed. If it is something that you still would like to have, please consider opening a PR. Thanks!