Hi,
Is it possible to bind the itemssource of the GridPickerColumn to a list on the actual model itself rather than a list on the viewmodel?
So on my viewmodel there is a property:
GridItems
And a GridItem object has a property ExpenseGroups on it. How can I bind to that?
<sfgrid:SfDataGrid.Columns> <sfgrid:GridPickerColumn MappingName="GlobalId" ItemsSource="{Binding ExpenseGroups}" DisplayMemberPath="Name" ValueMemberPath="Id" HeaderFontAttribute="Bold" HeaderText="Group"> </sfgrid:GridPickerColumn> <sfgrid:GridSwitchColumn MappingName="ActiveFlag" HeaderText="Active?"></sfgrid:GridSwitchColumn> </sfgrid:SfDataGrid.Columns>
| this.dataGrid.CellRenderers.Remove("Picker"); this.dataGrid.CellRenderers.Add("Picker", new CustomGridCellPickerRenderer()); ... public class CustomGridCellPickerRenderer : GridCellPickerRenderer { public override void OnInitializeEditView(DataColumnBase dataColumn, GridPicker view) { base.OnInitializeEditView(dataColumn, view); // Here Data is a Model class view.ItemsSource = (dataColumn.RowData as Data).ExpanseGroup; } ..... // model class public class Data : INotifyPropertyChanged { private double no_1; private double? no_2; private string text; private string id; public double No_1 { get { return this.no_1; } set { this.no_1 = value; RaisPropertyChnaged("No_1"); } } public string Id { get { return this.id; } set { this.id = value; RaisPropertyChnaged("Id"); } } public double? No_2 { get { return this.no_2; } set { this.no_2 = value; RaisPropertyChnaged("No_2"); } } public List<PickerInfo> ExpanseGroup { get; set; } private DateTime? orderDate; public DateTime? OrderDate { get { return orderDate; } set { this.orderDate = value; RaisPropertyChnaged("OrderDate"); } } public string Text { get { return this.text; } set { this.text = value; RaisPropertyChnaged("Text"); } } public Data() { ExpanseGroup = new List<PickerInfo>(); } public event PropertyChangedEventHandler PropertyChanged; private void RaisPropertyChnaged(string propertyName) { if (this.PropertyChanged != null) { this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } } public class PickerInfo { public string Name { get; set; } public string Id { get; set; } } |