ListView Virtualization value repeating in Recycling Mode

本秂侑毒 提交于 2019-12-05 12:55:28

That's certainly an odd effect, but it's seems to be due to the recycling mode plus the fact you're not binding the TextBox.Text property to anything.

Change your code like this (sorry for change of names) and all should be well:

public class RecyclingListViewModel
{
    public RecyclingListViewModel()
    {
        Items = new List<DataItem>();

        for (int i = 0; i <= 5000; i++)
        {
            Items.Add(new DataItem{Id = i, Name = i.ToString(CultureInfo.InvariantCulture)});
        }
    }

    public List<DataItem> Items { get; set; }
}

public class DataItem
{
    public int Id { get; set; }
    public string Name { get; set; }
}

<ListView ItemsSource="{Binding Path=Items}" >
<TextBox  MinHeight="20" MinWidth="200" Margin="4" Text="{Binding Name}"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!