Answer the question
In order to leave comments, you need to log in
How to update view when adding column to DataGrid?
Hello.
There is a table
<DataGrid ItemsSource="{Binding DataView, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
private DataView _dataView;
public DataView DataView
{
get => _dataView;
set
{
_dataView = value;
NotifyPropertyChanged();
}
}
public DelegateCommand<object> CmdUserCellEdit => new DelegateCommand<object>(arg =>
{
var cell = arg as DataGridCellEditEndingEventArgs;
if (cell.Column.SortMemberPath == "UserName")
{
var tb = cell.EditingElement as TextBox;
string tbText = tb.Text.ToString();
DataView.Table.Columns.Add(tbText);
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question