RadGridView with ItemsSource of ObservableCollection<string> does not allow row additions or edits
Environment
Product Version | 2019.1.220 |
Product | RadGridView for WPF |
Description
Since RadGridView is designed to work with collections of business objects, a lot of the core functionality would not work when the ItemsSource of the control is set to a collection of strings.
Solution
In order to avoid that, we can create a simple wrapper class around the string data.
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var wrappedData = from str in new List<string>() { "one", "two", "three" }
select new StringWrapper { Text = str };
this.gridView.ItemsSource = wrappedData;
}
}
public class StringWrapper
{
public string Text { get; set; }
}
<telerik:RadGridView x:Name="gridView" />