Question: How do I add to a ListView after the ListWrapper has been initilized?
See original GitHub issueI have a use case where I would like to update the underlying datasource for my ListView. I was hoping I could simply .Add() or .Remove() from the underlying IList datasource but that doesn’t seem to be the case. Is my only option to set the ListView.Source property with a new IList?
Example
private static List<string> source1 = new List<string>() { "Header" };
public static void Main()
{
Application.Init();
var window = new Window() { Height = Dim.Fill() ,Width = Dim.Fill() };
Application.Top.Add(window);
var list1 = new ListView(source1) { Width = 8, Height = Dim.Fill() };
window.Add(list1);
var index = 1;
Application.MainLoop.AddTimeout(TimeSpan.FromSeconds(1), loop =>
{
source1.Add($"Item {index++}"); // These are not rendered
return true;
});
Application.Run();
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:11
Top Results From Across the Web
Question: How do I add to a ListView after the ListWrapper ...
Question : How do I add to a ListView after the ListWrapper has been initilized? #834 ... Init(); var window = new Window()...
Read more >c# - Initializing ListView, why can't I do this?
This will create a List (an expandable collection); create a new ListViewItem in a loop, give that ListViewItem the text you want it...
Read more >Release notes - @pnp/spfx-controls-react
Fix for the ListView control when selection is used in combination with setState . Beta 1.0.0-beta.7¶. New control(s)¶. Grouping functionality added to the ......
Read more >Index (server-common-api)
Returns a token when an action is initialized If there is a custom callback, there needs to be a custom layout to render...
Read more >Issue with ObservableCollection in .net MAUI
When I open the app it reads the sqlite database and populates the ListView however when I add a new entry to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @BDisp for an attempted workaround. However I was hoping I could essentially use an expression as my IList source. To answer my own question, I realized that using a Property accessor actually calls the Get method and thus returns a temporary value. It is not a reference to the dictionary source. Here is the stackoverflow question I found talking about it.
I think what I’ll do is create my own implementation of IListDatasource that takes an Expression and see if that will work for my use case.
This will work too, but will cause the list to scroll as things are added. That is not always wanted.