Adds support for dynamic columns to DataGrid for WPF/UWP/Uno platforms.
Install-Package H.DynamicColumns.Core
Install-Package H.DynamicColumns.Wpf
Install-Package H.DynamicColumns.Uno
Install-Package H.DynamicColumns.Uno.WinUI
Install-Package H.DynamicColumns.Uwp
- Install
H.DynamicColumns.Core
to your core project that contains ViewModels. - Add property like this
public IReadOnlyCollection<DynamicColumn> DynamicColumns { get; }
to your ViewModel contains DataGrid ItemsSource. Your DynamicColumns should contain:
new DynamicColumn
{
Header = "Header",
BindingPath = $"Values[{index}]",
}
where
public class ItemViewModel
{
public ObservableCollection<string> Values { get; } = new();
}
- Bind in your platform project:
<DataGrid dynamicColumns:DataGridExtensions.DynamicColumns="{Binding DynamicColumns}">
where
xmlns:dynamicColumns="clr-namespace:H.DynamicColumns;assembly=H.DynamicColumns.Wpf"