Articles in this section
Category / Section

How to bind the view model ItemsSource to GridComboBoxColumn in WPF DataGrid (SfDataGrid)?

1 min read

You can bind the ViewModel ItemsSource to GridComboBoxColumn without StaticResourceKey by setting the ElementName when binding the ItemsSource from DataContext of WPF DataGrid (SfDataGrid) as shown in the below code example.

XAML

<syncfusion:SfDataGrid x:Name="dataGrid"
                       AllowEditing="True"
                       AutoGenerateColumns="False"                             
                       ItemsSource="{Binding OrderList}">
           <syncfusion:SfDataGrid.Columns>
               <syncfusion:GridTextColumn MappingName="ProductName" />
               <syncfusion:GridTextColumn MappingName="ProductId" />
               <syncfusion:GridTextColumn MappingName="CountryName" />
               <syncfusion:GridComboBoxColumn ItemsSource="{Binding Path=DataContext.Shipcities,ElementName=dataGrid}"  MappingName="ShipCity" />
           </syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>

View sample in GitHub.

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please sign in to leave a comment
Access denied
Access denied