I’m currently struggling with DataGrid in WPF MVVM
What I have is DataGrid, that is binded to one collection. It is displayed in DataGridTextColumn as expected and populates DataGrid. Let’s imagine I have 10 items in it. But what I need also is to have one DataGridComboBoxColumn in each row, that would be binded to the separate collection. It should contain its own values, that have no attitude to the first collection. Using that DataGrid user will determine the binding between 2 collections that are not connected logically.
The XAML code is:
<DataGrid Grid.Column="0" AutoGenerateColumns="False" CanUserAddRows="False"
ItemsSource="{Binding Path=ItemNamesSetting}">
<DataGrid.Columns>
<DataGridTextColumn Header="Initial Name item" Binding="{Binding Path=OriginalItemName}" />
<DataGridTextColumn Header="Final Name item" Binding="{Binding Path=FinalItemName}" />
<DataGridComboBoxColumn Header="Belongs to" Width="*"
ItemsSource="{Binding Path=AttributesBindingList}"
DisplayMemberPath="PropName"/>
</DataGrid.Columns>
</DataGrid>
Though it displays empty rows in ComboBox. I have seen multiple examples, that are working with DataGridComboBoxColumn bindings to the data, connected between collections by some external key. But I have 2 different collections, that are not connected.
Can you take a look where I’m wrong with this binding?