This question is locked. New answers and comments are not allowed.
Good day.
I use column auto-generation on the dynamic collection as a source. Previous post link
But DataContext for generated Cell(FrameworkElement) is entire RowItem (System.Dynamic.ExpandoObject).
Thus, the problem is that the template does not know the names of the properties.
Therefore, I need to pass only one property to the datacontext of the cell and not the entire RowItem.
Maybe there is a way to somehow pass the binding on the current property for the entire column?
Or somehow in the code at generation of a cell to transfer to it the necessary datacotext property?
{ public ObservableCollection<System.Dynamic.ExpandoObject> Items { get; set; }}<controls:RadDataGrid x:Name="TableViewRelatedObjects" HorizontalAlignment="Stretch" DataContext="{x:Bind ViewModel}" ItemsSource="{x:Bind ViewModel.Items, Mode=OneWay}" AutoGenerateColumns="True" UserGroupMode="Disabled"></controls:RadDataGrid>
private DataTemplateSelector _fieldTemplateSelector;public CustomGenerateColumnCommand(DataTemplateSelector fieldTemplateSelector){ this.Id = Telerik.UI.Xaml.Controls.Grid.Commands.CommandId.GenerateColumn; _fieldTemplateSelector = fieldTemplateSelector;}public override bool CanExecute(object parameter){ var context = parameter as GenerateColumnContext; // put your custom logic here return true;}public override void Execute(object parameter){ var context = parameter as GenerateColumnContext; var template = _fieldTemplateSelector.SelectTemplate(context.PropertyName); var column = new DataGridTemplateColumn() { CellContentTemplate = template }; context.Result = column; return; };}
