|
public class BindingProxy : DependencyObject
{
public BindingProxy() { }
//Dependency property Data for holding ComboBox ItemsSource value.
public object Data
{
get { return (object)GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}
// Using a DependencyProperty as the backing store for Data. This enables animation, styling, binding, etc...
public static readonly DependencyProperty DataProperty =
DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new PropertyMetadata(null));
} |
|
<Page.Resources>
<local:BindingProxy x:Key="proxy" Data="{Binding}"/>
</Page.Resources>
<syncfusion:SfDataGrid.Columns>
<!--Binding Dependency object in GridComboBoxColumn-->
<syncfusion:GridComboBoxColumn HeaderText="City" ItemsSource="{Binding Data.ItemsCollection, Source={StaticResource proxy}}" AllowEditing="True"
DisplayMemberPath="Key" SelectedValuePath="Value"
MappingName="City" />
</syncfusion:SfDataGrid.Columns>
|
|
Query 1: dynamically assign ItemsSource to GridComboBoxColumn at runtime. |
You can assign the ItemsSource to GridComboBoxColumn at runtime like below code example.
We have prepared the sample based on your requirement, you can download it from below mentioned location.
Sample location: http://www.syncfusion.com/downloads/support/directtrac/general/ze/GridComboBoxDemo-338419722
| |
|
Query 2: Still GridComboBoxColumn as Empty |
We had noticed that in your given code, you had assign the ItemsSource to field instead of property at runtime. Now we have modified the given files in that sample, you can download it from below mentioned location.
Sample location: http://www.syncfusion.com/downloads/support/directtrac/general/ze/GridComboBoxDemo1-1347191728
|