'Best WPF control to display a dynamic editable list of strings
I am looking for the proper WPF control(s) to display a list of strings subject to the following constraints:
- The user can edit the single item
- There may be some "empty" items
- The code must have access to the list content before and after the editing
Maybe a ListBox or a ListView. Despite spending many hours searching for documentation and examples I am not sure yet if and how to make the list items editable. I am a novice... sigh
Thank you in advance.
Solution 1:[1]
You can use DataGrid which is an editable Gridview.
You should create a class to bind DataGrid like as shown
public class MyItem
{
public string Item { get; set; } = stirng.empty;
}
Then create control in XAML
<DataGrid x:Name="dgList" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Databases" Binding="{Binding Value}" />
</DataGrid.Columns>
</DataGrid>`
Then you can write binding
string aa = "aa,xx,cc,vv,bbb,hh,gg,rr,tt,yy,uu,ooo";// add your list from DB
dgList.ItemsSource = aa.Split(',').Select(x => new MyItem() { Item = x });
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rijwan Ansari |
