You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
WrapLayout is not updating correctly when source collection is changed.
Consider an ItemsRepeater bound to a changing source collection "CurrentNode.Things".
With <UniformGridLayout /> the ItemsRepeater displays the correct items from "CurrentNode.Things" as CurrentNode changes.
If I change to <WrapLayout />, the number of displayed items updates correctly, but any items from the previous source are displayed instead.
In the example below, the UniformGridLayout is left, and WrapLayout on the right...
To Reproduce
public class Thing
{
public string? Name { get; set; }
}
public class FolderNode
{
public ObservableCollection<Thing> Things { get; set; } = new ObservableCollection<Thing>();
public FolderNode(List<string> Names)
{
foreach (string c in Names)
{
Things.Add(new Thing { Name = c });
}
}
}
public class MainWindowViewModel : ViewModelBase
{
private FolderNode _currentNode = default!;
public FolderNode CurrentNode
{
get => _currentNode;
set
{
this.RaiseAndSetIfChanged(ref _currentNode, value);
}
}
ObservableCollection<FolderNode> Folders { get; set; } = new ObservableCollection<FolderNode>();
public ICommand SelectFolderCommand { get; }
public MainWindowViewModel()
{
Folders.Add(new FolderNode(new List<string>()));
Folders.Add(new FolderNode(new List<string>() { "A", "B" }));
Folders.Add(new FolderNode(new List<string>() { "D", "E", "F" }));
CurrentNode = Folders[0];
SelectFolderCommand = ReactiveCommand.Create<string>(param =>
{
CurrentNode = Folders[int.Parse(param)];
});
}
}
<ItemsControl> with a <WrapPanel> doesn't seem to suffer from the same issue as <ItemsRepeater> with a <WrapLayout>.
I'm not sure if you lose anything like virtualization support or what not when you make the switch, but if ItemsRepeater and ItemsControl are interchangeable in your case, just change
Description
WrapLayout is not updating correctly when source collection is changed.
Consider an ItemsRepeater bound to a changing source collection "CurrentNode.Things".
With
<UniformGridLayout />
the ItemsRepeater displays the correct items from "CurrentNode.Things" as CurrentNode changes.If I change to
<WrapLayout />
, the number of displayed items updates correctly, but any items from the previous source are displayed instead.In the example below, the UniformGridLayout is left, and WrapLayout on the right...
To Reproduce
Expected behavior
WrapLayout should display the correct items from source!
Desktop:
The text was updated successfully, but these errors were encountered: